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?