ioscocoaasyncsocket

Is it possible to build socket connection between 2 iOS devices


Is it possible to build a socket connection between 2 iOS devices connected to the same network (Without net)?

if it's possible .. Is (CocoaAsyncSocket project) useful for me?

I just want to send a message from Device A to Device B which put the app in background .. when Device B receive the message should show notification to return the app to foreground.

It's not for the App Store, so I don't care if Apple would reject the app because of this behavior.


Solution

  • Yes, you can do it, and yes, CocoaAsyncSocket would be useful. If you don't have to worry about the carrier network's firewalls and filters, then you should certainly be able to build a client-server app running on two iOS devices. One opens the server socket to listen, and the other one (the client) connects, via the Wi-Fi network.

    Trying searching on Google (e.g. "CocoaAsyncSocket iPhone iOS site:stackoverflow.com") or directly here on Stack Overflow.

    Here's somebody who seems to have accomplished this

    Another link

    And a post from Robbie Hanson himself, referring you to the EchoServer projects in the github repository

    EchoServer project

    You may have to use a static IP address for the server device (I'm not sure how much control you have over the Wi-Fi network's configuration), or use some other mechanism for letting the two devices discover each other.