In Socket Programming, how will a Unix thread receive a Socket CLOSE event from a client if connection is closed?
Are there any API’s which will notify the unix thread about the CLOSE event received?
As in Windows we have WSAEnumNetworkEvents API which gets the event notification for a specified socket descriptor. What will be the equivalent API used in the Unix socket programing?
Please provide the help for the query.
You can track the closure event when performing reading. The socket is closed when
readreturns 0 (talking about “Berkeley sockets” of course).//EDIT:
Use
pollorselectto wait for some event to occur (data arrival, socket closure …).