By using select function handling multiple client connection in RPI using c. If CLOSE_WAIT came code is not working.if it occurs I am trying to kill the socket but code is hanging. Without restart how to resolve this Please help in this.....
When CLOSE_WAIT will come how to avoid this.
I am thinking it will come if we didn't close the socket but how to close during network loss. Or else How to do read timeout on server side
CLOSE_WAIT
happens on the server side only when a client gracefully closes its end of the connection (ie sends aFIN
packet) before the server closes its end. Once the server has closes its end, the connection transitions out ofCLOSE_WAIT
. A connection being inCLOSE_WAIT
will not prevent the server from handling other connections. It sounds like your server is simply not closing its sockets properly, such as if it is not handling socket close/error notifications correctly.close()
'ing accepted sockets if theclients[]
array is full. And it is handling errors fromsend()
andread()
at all. But it is handling graceful disconnects, at least, and should beclose()
'ing sockets for disconnected clients. But it is notclose()
'ing sockets for lost clients.CLOSE_WAIT
actually is. The code shown can't hang ifCLOSE_WAIT
occurs. Something else is going on. Like maybe no new client connecting to your server. Use a timeout withselect()
. Also,select()
isn't the best choice for error handling.epoll()
is a better option.