我正在使用此代码连接输入和输出流:
Stream.getStreamsToHost(withName: self.IPAddress!,
port: 7999,
inputStream: &inputStream,
outputStream: &outputStream)
inputStream?.delegate = delegate
outputStream?.delegate = delegate
inputStream?.schedule(in: RunLoop.current,
forMode: RunLoopMode.defaultRunLoopMode)
outputStream?.schedule(in: RunLoop.current,
forMode: RunLoopMode.defaultRunLoopMode)
inputStream?.open()
outputStream?.open()
但是当我打开流时,出现以下错误:
2018-09-24 16:57:58.544411 + 1200 wifi-jam-ios [5518:5502956] [] nw_connection_get_connected_socket 2连接没有连接的处理程序 2018-09-24 16:57:58.544526 + 1200 wifi-jam-ios [5518:5502956] TCP Conn 0x1c0166d80失败:错误0:61 [61] 流(_:handle :) NetServiceManager:发生错误 流(_:handle :) NetServiceManager:发生错误
流在其他地方声明:
var inputStream: InputStream?
var outputStream: OutputStream?
我使用getStreamsToHost
方法不正确吗?