Re: Socket.Connected by EtienneFortin
EtienneFortin
Thu Jul 21 07:16:12 CDT 2005
Thanks for your answer.
It is a probably a good way to know if a connection is dead. But what about
the situation when the client didn't send any data for a certain period of
time, but it is still connected and alive? Receive() will return zero bytes.
Etienne
"Markus Stoeger" wrote:
> Etienne Fortin wrote:
>
> > Hi there,
> > I'm playing with Socket and Telnet (via hyperterminal). I'm trying to
> > display a message when the client disconnect, that is when hyperterminal
> > either close the connection, or is closed, on the client side. But,
> > Socket.Connected always seems to return true, even though I do as in the
> > doc and do a 0 byte Send before checking its value.
> >
> > Is there another way to know if a Socket is still connected to a client?
>
> Try to do a receive on the socket. It normally returns the number of bytes
> received.. but when the connection has been closed it will return 0 bytes.
>
> hth,
> Max
>