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:
pollinwhen there data read, , whenreadorrecvfunction call, make sure checked return value, typically return value of0indicates connection has been shutdown. same previous single client version.pollrdhupindicates peer has closed connection, or shut down writing half of connection.pollerrother errors.
when 3 event triggered, means client has closed connection or there errors on socket, typically close sockets.
Comments
Post a Comment