Receiving Error Domain=kCFErrorDomainCFNetwork Code=2 when attempting to read from ReadStream

后端 未结 3 1009
忘了有多久
忘了有多久 2021-01-17 11:37

I\'m attempting to synchronously read from a CFReadStream objected created by CFStreamCreatePairWithSocketToHost. The stream opened fine but when I

3条回答
  •  感动是毒
    2021-01-17 12:13

    I was able to eliminate this error by removing https:// from the host String.

    NSStream.getStreamsToHostWithName("https://example.com" ...

    You may need to set the appropriate security level:

     inputStream!.setProperty(NSStreamSocketSecurityLevelTLSv1, forKey: NSStreamSocketSecurityLevelKey)
    outputStream!.setProperty(NSStreamSocketSecurityLevelTLSv1, forKey: NSStreamSocketSecurityLevelKey)
    

提交回复
热议问题