新4.0 API:WifiP2pManager...如何传输数据?
在新的 Ice Cream Sandwich SDK (4.0) 中,API 中有一个新部分用于通过 wifi 创建 p2p 连接。 WifiP2pManager 类中有大量关于如何操作的信息连接并发现对等点和对等组,但很少详细介绍如何在建立连接后发送数据。它说:
连接信息WifiP2pInfo包含组的地址 所有者 groupOwnerAddress 和一个标志 isGroupOwner 来指示是否 当前设备是 p2p 组所有者。 p2p 客户端因此可以进行通信 通过套接字连接与 p2p 组所有者。
我在创建套接字连接方面没有丰富的经验。 仅通过 WifiP2pInfo 或连接方法,对等点发送数据以及对等组所有者接收数据需要什么?
In the new Ice Cream Sandwich SDK (4.0), there is a new section of the API for creating p2p connections over wifi. There is plenty of information in the WifiP2pManager class on how to connect and discover peers and peer groups, but very little detail on how to send data after a connection is established. It says:
The connection info WifiP2pInfo contains the address of the group
owner groupOwnerAddress and a flag isGroupOwner to indicate if the
current device is a p2p group owner. A p2p client can thus communicate
with the p2p group owner through a socket connection.
I don't have a ton of experience with creating socket connections. What would be needed for a peer to send data, and for a peer group owner to receive it, just from the WifiP2pInfo or connection methods?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为新手,关于这方面的信息并不多,但是 Android 开发人员资源中的示例应用程序是一个很棒的演示项目,它为我提供了我需要了解的一切。
WiFiDirectDemo 项目
使用
WiFiP2pInfo
,您可以打开一个套接字进行数据传输。演示中有一个发送文件的示例。Being new, there isn't a lot of information on this, but the sample application from the android developers resources is a fantastic demo project that gave me everything I needed to know.
WiFiDirectDemo Project
With the
WiFiP2pInfo
, you can open a socket for data transmission. It has an example for sending files in the demo.