如何在连接到 WiFi 接入点的设备之间进行通信?
我有几部手机和另外几部电脑连接到 Wifi 接入点,需要在其中任何一个之间发送和接收消息,我的意思是任何人都可以向任何人发送消息并从任何人接收消息。
我愿意在手机(Symbian OS、S60 平台)或 PC(Windows)上编写应用程序,但我不明白的是如何设置客户端或服务器,因为这些设备中的任何一个都可以是客户端或服务器。
如果我使用套接字,我是否必须为每个设备上的 ServerSockets 和 Sockets 编写脚本?我可以使用HTTP 协议吗?
或者我可以使用任何标准协议来实现这一点?
I have got a couple of phones and another couple of PC's connected to a Wifi access point and need to send and receive messages between either of these, I mean anyone can send a message to anyone and receive a message from anyone.
I am willing to write apps on the phones(Symbian OS, S60 platform) or PC(Windows), but what I can't understand is how do I set up a client or server, since any one of these devices could be a client or server.
If I use sockets do I have to script for ServerSockets and also Sockets on each of these devices? Can I use the HTTP protocol?
Alternatively any standard protocol that I could use to implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将广播 UDP 数据包,这些数据包将到达 Wifi 网络上的每个设备。您必须发明自己的协议来决定每个设备的身份,因为您无法轻松推断出网络设备的 IP 地址。如果不编写选举算法,您会发现很难使用客户端/服务器架构,因此只需使用点对点(P2P)即可。
Google 查找 UDP 广播并阅读 ietf.org 上的相关 RFC。
You would broadcast UDP packets which would arrive at every device on the Wifi network. You would have to invent your own protocol to decide on the identity of each device, since you wouldn't be able to easily infer the IP addresses of your network devices. Without writing an election algorithm you would find it difficult to use a client/server architecture, so just use point-to-point (P2P).
Google for UDP broadcasts and read the relevant RFCs at ietf.org.
您似乎正在寻找非常典型的 IP 点对点通信。我想其他要求将决定您使用哪种传输(HTTP、原始套接字等),但是是的:每个节点都将既是客户端又是服务器。您可以使用 MDNS (http://www.multicastdns.org/) 来帮助节点找到彼此以临时的方式。
It seems like you're looking for pretty typical peer-to-peer communication over IP. I suppose other requirements will dictate which transport you use (HTTP, raw sockets, etc), but yes: Each node will be both a client and a server. You could possibly use MDNS (http://www.multicastdns.org/) to help the nodes find eachother in an ad-hoc manner.