是否可以在2个iOS设备之间建立套接字连接 [英] Is it possible to build socket connection between 2 iOS devices

查看:74
本文介绍了是否可以在2个iOS设备之间建立套接字连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在连接到同一网络(无网络)的2个iOS设备之间建立套接字连接?

如果可能的话..(CocoaAsyncSocket项目)对我有用吗?

我只想从设备A 发送一条消息到设备B,这会在设备B 收到应用程序后将应用置于后台.消息中应显示通知,以使应用程序返回到前台.

它不是用于App Store的,所以我不在乎Apple是否会因为这种行为而拒绝该应用程序.

解决方案

,您可以做到,CocoaAsyncSocket会很有用.如果您不必担心运营商网络的防火墙和过滤器,那么您当然应该能够构建在两个iOS设备上运行的客户端-服务器应用程序.一个打开 server 套接字进行监听,另一个打开( client )通过Wi-Fi网络进行连接.

尝试在Google(例如"CocoaAsyncSocket iPhone iOS site:stackoverflow.com")上或直接在Stack Overflow上进行搜索.

这是​​>似乎已经做到这一点的人

另一个链接

Robbie Hanson本人的帖子,向您介绍了github存储库

EchoServer项目

您可能必须为服务器设备使用静态 IP地址(我不确定您对Wi-Fi网络的配置有多少控制权),或使用其他机制让两个设备相互发现.

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.

解决方案

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.

这篇关于是否可以在2个iOS设备之间建立套接字连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆