Is it possible to build socket connection between 2 iOS devices

南笙酒味 提交于 2019-12-09 06:53:07

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/12450597/is-it-possible-to-build-socket-connection-between-2-ios-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!