vichargrave/tcpsockets

file descriptor not closing

Closed this issue · 3 comments

Hey,
we just discovered that in the TCPConnector::connect method is an issue with open file descriptors. If there is an error with the attempt to connect, the opened file descriptor is not being closed again. On multiple connection attempts at short time, there will be too many opened file descriptors and the call results in a bad file descriptor error.

Our proposal as a fix would be to exchange the code in line 105 with

if (result == -1) {
    close(sd);
    return NULL;
}

Edit: Of course the same is valid for the TCPConnector::connect method without the timeout parameter

Yes that is a good catch. I'll fix it immediately. Many thanks.

I just updated the code to call close() in both the blocking and non-blocking TCPConnector::connect methods. I'm going to go ahead and close this issue. Let me know if any other issues arise.

Marking issue closed.