Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

Socket.Connected

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Etienne Fortin - 20 Jul 2005 18:37 GMT
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?

Etienne Fortin
Markus Stoeger - 20 Jul 2005 22:07 GMT
> Hi there,
> I'm playing with Socket and Telnet (via hyperterminal). I'm trying to
[quoted text clipped - 4 lines]
>
> 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
Etienne Fortin - 21 Jul 2005 13:16 GMT
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

> > Hi there,
> > I'm playing with Socket and Telnet (via hyperterminal). I'm trying to
[quoted text clipped - 10 lines]
> hth,
> Max
Markus Stoeger - 22 Jul 2005 22:35 GMT
> 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.

If you are using blocking sockets, Receive will not return 0 bytes unless
the client disconnected. If you call Receive but there is no data
available, Receive will block and wait until there is data available or
until the client disconnects (in which case it would return 0 bytes).

Max

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.