I don't know enough about the networking library to figure out the exact cause of the bug, but there seem to be two things that the blocking connect() function does that are not done when using NoBlockConnect() + close():
1. Sets the TCP_USER_CLOSED flag in gpflags (But I think this is done in _Socket_Private_close() further down the call stack so it doesn't seem like an issue)
2. Calls DoClose(TCP_ERR_TIMEOUT) - when using the standard close() function it's going to be DoClose(TCP_ERR_NORMAL) instead
I ended up adding my own function to tcp.cpp to do these things, and it seems to work, but I prefer not to modify the system files if not absolutely necessary. Is there any existing functionality I should be using to close these sockets?
For reference, here is my function
Code: Select all
void NoBlockClose(int fd)
{
int sl = fd - TCP_SOCKET_OFFSET;
register PSOCKET ps = sockets + sl;
ps->gpflags |= TCP_USER_CLOSED;
ps->DoClose( TCP_ERR_TIMEOUT );
}
Thanks,
David