Check if a socket in Windows is connected or not
Posted on 2011-10-04
I have a DLL that opens a socket connection, and handles everything. I have another DLL set up, called from the same program, that I would like to pass the socket to and have it check to see if the socket is still connected or not.
Something like this:
..do other work, such as connect, etc...
int ret = isSocketConnected(sock);
And have the return code be a negative number if the socket isn't connected anymore, and anything other than a negative number if the socket IS connected and there are no existing errors. If possible, I want to do this without recv() as I want to leave the data in the pipe, so my program can handle it. This will simply be to check and see if the socket is still connected, so I can re-connect if needed.
Is this possible?