Re: Cable disconnected event
Re: Cable disconnected event
- Subject: Re: Cable disconnected event
- From: "Peter Sichel" <email@hidden>
- Date: Tue, 15 May 2007 11:27:12 -0400
On 5/14/07, Marco Bambini wrote:
>Hi all,
>
>I am writing a server using C code and sockets.
>Everything is working fine but the problem is that if the server is
>blocked in a select statement waiting for commands from the client
>side, if the network cable is disconnected then there is no way for
>the server to know that the client is disconnected. Is there a way to
>check for this kind of events? Is polling the client the only
>solution to the "cable disconnected" event?
There are two pieces you might want to consider:
(1) Getting the System Configuration Framework to notify
you when a network connection is no longer available
(Reachability API).
(2) Using "select" with time out (Stevens UNIX Network Programming)
and/or selecting on another fd connected to a pipe so you can
tell the select to abort by writing to the other end of
the pipe.
I use both techniques to abort a server listening on a socket.
Kind Regards,
- Peter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden