Swift NWConnection-接收失败,错误为“;“流媒体上没有可用消息”;

Swift NWConnection-接收失败,错误为“;“流媒体上没有可用消息”;,swift,networking,tcp,stream,Swift,Networking,Tcp,Stream,我目前正在使用iOS应用程序,需要连接到其他设备。NWConnection是使用TCP成功建立的,我可以从远程设备接收一条(并且只有一条)消息,并立即收到错误。连接被取消(我想是错误造成的)。 控制台日志显示: Hello World. [connection] nw_flow_add_read_request [C1 <ip and port of remote device> ready channel-flow (satisfied (Path is satisfied), v

我目前正在使用iOS应用程序,需要连接到其他设备。NWConnection是使用TCP成功建立的,我可以从远程设备接收一条(并且只有一条)消息,并立即收到错误。连接被取消(我想是错误造成的)。 控制台日志显示:

Hello World.
[connection] nw_flow_add_read_request [C1 <ip and port of remote device> ready channel-flow (satisfied (Path is satisfied), viable, interface: en0, ipv4, ipv6, dns)] already delivered final read, cannot accept read requests
[connection] nw_read_request_report [C1] Receive failed with error "No message available on STREAM"
error
远程设备只发送一个包,若要接收更多包,将再次调用该方法

编辑:我打印了错误消息并得到

error: Optional(POSIXErrorCode: No message available on STREAM)

这似乎与POSIXError ENODATA有关。

您找到过解决方案吗?我自己刚碰到这个不幸的不是