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

后端 未结 3 1008
忘了有多久
忘了有多久 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:29

    The short story: Probably a DNS resolution failure.

    The docs say "The streams do not open a connection to the specified host until one of the streams is opened", and for kCFGetAddrInfoFailureKey,

    Querying this key returns the last error code returned by getaddrinfo(3) in response to a DNS lookup. To interpret the results, look up the error code in /usr/include/netdb.h.

    netdb.h says

    #define EAI_NONAME  8  /* hostname nor servname provided, or not known */
    

提交回复
热议问题