macvek
macvek

Reputation: 46

Connect() from ios to ios device in same subnet

I develop IOS app, which needs to make standard TCP connection from one iPhone(or iPod) to another. Connection works well between apps on simulator and device, as well as between two simulators.

Application uses posix connect() and I have to stick to this method, because other modules are pure C.

When invoking connect() application blocks, and after timeout error is returned. The communication is via wifi in LAN

I've sniffed the traffic and encountered, that after connecting to simulator, device sends ARP and after answer, standard TCP handshake proceeds and session is made.

Same case with iPhone<>iPhone stops after ARP request, because another iPhone doesn't respond to it. Moreover iOS sends only gratuitous ARP (announces it's mac ip pair). My MAC seems like proceeding this request, because its ARP table has iPhone record, it doesn't work for another iPhone.

I've tried bonjour service, but it also works only with simulator <> device.

My question: Is there any way to allow such communication? Is it possible it is problem with my iPhones only? Is there any explicit way to tell OS to send response for arps, or is it somehow blocked for traffic ios<>ios communication.

Upvotes: 1

Views: 620

Answers (1)

Moebius
Moebius

Reputation: 700

Not sure if this will help, but I am working on a project that is doing something similar with devices announcing themselves on a network. We are using SSDP to send out an alive request from one device and other devices are listening on the multicast address and port. Once each device receives the alive, it sends out a response with all if its pertinent information, including IP Address and port. Unfortunately, SSDP is a send and forget type of protocol, so there are issues there. We use the IP Address and port information to send messages directly to each device.

Again, not sure if this helps in your situation, but I've seen this work very well so far.

Upvotes: 1

Related Questions