c - Connection loss detection with poll() -
i making client server application. in application if client went down server try reconnect ( i.e. if recv()
on server side returns 0 value server go accept connection ). want modify server allowing connect multiple clients. thought of using poll()
server check on each client sometime. wanted know poll
how can check if connection client lost?
when use multiplex io poll
, can handle connection shutdown following events:
pollin
when there data read, , whenread
orrecv
function call, make sure checked return value, typically return value of0
indicates connection has been shutdown. same previous single client version.pollrdhup
indicates peer has closed connection, or shut down writing half of connection.pollerr
other errors.
when 3 event triggered, means client has closed connection or there errors on socket, typically close sockets.
Comments
Post a Comment