Re: How to detect if the other end of the TCP connection has gone offline



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@xxxxxxxxxxx>:
> 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@xxxxxxxx
> For additional commands, e-mail: beginners-help@xxxxxxxx
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
.



Relevant Pages

  • Re: newbie socket question
    ... | When i use the ip address 64.12.161.153 which is the correct server it says ... three packets that has to be exchanged in order to complete the connection. ... When you connect, you send out the first packet, and your side of the ... get the data or EOF. ...
    (comp.os.linux.development.apps)
  • Packet cap diff... for classic dhcp over winxp s/w bridge prob.
    ... the server simultaneously. ... DHCP Discover - Transaction ID 0xe5448fbb ... Time delta from previous packet: ... Time since reference or first frame: ...
    (comp.os.linux.networking)
  • Interesting TCP behaviour with large sends/small buffers
    ... The server, upon connection, sends a configurable number of bytes to ... I set the client's receive buffer size to 1MBps, ... packet before sending the next packet. ... ACK, according to the delayed ACK algorithm - 50KB bytes means 34 MSS- ...
    (microsoft.public.win32.programmer.networks)
  • Re: How to terminate a socket in CLOSE_WAIT state
    ... FTP Server fixed for certain FTP clients who use both passive ... This was causing a PASSIVE opened socket to be left ... but instead expect the "half close" from the receiver. ... this sends a TCP/IP FIN packet to the ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Sockets class question - sending TCP data
    ... Announcement DEV02, Workstation, Server, SQL Server, NT Workstation, NT ... Time delta from previous packet: ... Receiver's Name: DYNAMICSYSTEMS(Local Master Browser) ... You say that you did this in a Java applet. ...
    (microsoft.public.dotnet.languages.csharp)