Home > Archive > PERL Beginners > October 2005 > How to detect if the other end of the TCP connection has gone offline
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to detect if the other end of the TCP connection has gone offline
|
|
| Karjala 2005-10-31, 9:55 pm |
| I'm writing a simple client-server application, and I'm trying to find a
way to tell if the other end of an open TCP connection has gone offline.
I heard that with C you can send a packet of data and check if an ACK
packet comes back. If it doesn't then the connection is closed. But how
can that be done with Perl?
I'm using the "IO::Socket" library, but if "Socket" can do it, I'm
willing to revert to that.
Thanks for your time,
- Karj.
| |
| Jeff Pang 2005-10-31, 9:55 pm |
| On client side, you can write:
$sock->shutdown(1);
to send an EOF to remote server.
When the server receive the EOF,it will end of writing socket to
client,and send back an EOF to client.At this point,the socket talks
between client and server have finished.
2005/10/31, Karjala <karjala_lists@karjala.org>:
> I'm writing a simple client-server application, and I'm trying to find a
> way to tell if the other end of an open TCP connection has gone offline.
>
> I heard that with C you can send a packet of data and check if an ACK
> packet comes back. If it doesn't then the connection is closed. But how
> can that be done with Perl?
>
> I'm using the "IO::Socket" library, but if "Socket" can do it, I'm
> willing to revert to that.
>
> Thanks for your time,
> - Karj.
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
|
|
|
|
|