I need to know when a TCP RST packed is received

66 views
Skip to first unread message

Lyubomir Mihaylov

unread,
Apr 13, 2017, 10:13:01 AM4/13/17
to CocoaAsyncSocket
I need to differentiate between a socket being closed with RST or FIN. In iOS I am able to do that if using CFStream. In the stream method of NSStreamDelegate:

 - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)streamEvent

I get NSStreamErrorOccured and the streamError property of stream has code=54 ECONNRESET.

Using CocoaAsyncSocket  in case of TCP RST, on socketDidDisconnect I get a generic GCDAsyncSocketClosedError, which is not got from the socket, but set by CocoaAsyncSocket itself in doReadEOF. More then that I am not able to get the correct error code ECONNRESET looking at errno or calling

int error = getsockopt(sockFD, SOL_SOCKET, SO_ERROR, &errCode, &len);

Is there a way to get ECONNRESET somewhere in CocoaAsyncSocket when RST is received?
Reply all
Reply to author
Forward
0 new messages