【发布时间】:2019-10-22 18:04:29
【问题描述】:
我正在尝试通过 USB 在台式计算机和许多移动设备之间创建服务器-客户端连接。
对我来说,在桌面端创建一个套接字服务器来侦听特定端口以进行连接,同时让多个移动设备连接到该端口是有意义的。但是,the info I found on usbmuxd 说移动设备应该是套接字服务器:
In practice it is possible to **create a socket server in a free port from an iOS** App and to connect to it from the host machine sending the following command via the /var/run/usbmuxd Unix socket (File Descriptor):
<?xml version=”1 .0" encoding=”UTF-8"?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList1.0.dtd”>
<plist version=”1.0">
<dict>
<key>ClientVersionString</key>
<string>usbmuxd-423.206.4</string>
<key>DeviceID</key>
<integer>4</integer>
<key>MessageType</key>
<string>Connect</string>
<key>PortNumber</key>
<integer>My port</integer> <--- The port number (with endian transform htonl)
<key>ProgName</key>
<string>usbmuxd</string>
</dict>
</plist>
在 Android 中,adb forward tcp:<port1> tcp:<port2> 似乎通过转发桌面主机端口来做类似的事情,但主机本质上是一个套接字客户端。据我了解,主机必须知道任意设备上的所有端口,并且设备必须确保这些端口是唯一的,这使得与多个设备的握手过程难以自动化。
这是设计使然吗?难道就不能这样颠倒桌面端和移动端的服务器-客户端关系吗?
还是我错了?
【问题讨论】:
标签: android ios sockets mobile