Is there a way to get the socket reference by using CFStreamCreatePairWithSocketToHost()?

前端 未结 1 1873
余生分开走
余生分开走 2021-01-02 20:28

I am creating a socket tcp connection using CFStreamCreatePairWithSocketToHost like this to get a write stream (I dont want to ready any data):

         


        
相关标签:
1条回答
  • 2021-01-02 20:49
    CFDataRef socketData = CFWriteStreamCopyProperty(writeStream, kCFStreamPropertySocketNativeHandle);
    CFSocketNativeHandle handle;
    CFDataGetBytes(socketData, CFRangeMake(0, sizeof(CFSocketNativeHandle)), &handle);
    // handle now contains the same thing as CFSocketGetNative(aSocket)
    
    0 讨论(0)
提交回复
热议问题