wxSocketClient and handling a server dropped connection

Derek Lee-Wo dleewo at gmail.com
Fri May 2 14:45:34 PDT 2008


I have an app with a thread for handling a socket connection to a
server.  I'm NOT using asynchronous events.  I'm reading and writing
on the socket and blocking

My question is how can I detect that server has dropped the connection
while I'm blocked on a read?

The Read() returns when the connection is dropped and a call to
Error() returns true, but a subsequent call to LastError() returns a 0
meaning there was no error.

I guess I could _assume_ that an Error() after a read means a dropped
connection, but I was hoping LastError() would return wxSOCKET_IOERR
or something more appropriate.

Am I doing this wrong or is there a better way to detect that a socket
was closed on the server end?

Derek


More information about the wx-users mailing list