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, , when read or recv function call, make sure checked return value, typically return value of 0 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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -