SDLnet check if TCPsocket has closed connection

363 views Asked by At

How can I check if a SDLnet TCPsocket has closed the connection? I tried checking if the socket is NULL but it doesn't work, this is what I tried:

    for(int i = 0; i < clientConnections.size(); i++) {
        if(!clientConnections[i]) {
            clientConnections.erase(clientConnections.begin() + i);
            i--;
        }
    }

Also I haven't found anything in the documentation.

1

There are 1 answers

0
Some programmer dude On BEST ANSWER

There's no single utility function in SDLNet to check for a disconnection status, as it's really nothing more than a thin platform-independent wrapping around the underlying platforms network functionality which almost universally doesn't have such direct functionality.

With the SDLNet API it could be implemented using socket sets, which (as is the nature of SDLNet) wraps similar functionality of the most common OS network facilities.