PC Review


Reply
Thread Tools Rate Thread

Dead Socket Detection?

 
 
Bob L.
Guest
Posts: n/a
 
      23rd Jul 2004
Hi, everyone,

I am trying to test a client/server solution that uses the .NET Socket class
(blocking mode on the server). I need the server to be able to verify that a
socket is still valid in case the client app drops the connection (i.e. the
client app crashes). The Poll method and the Available and Connected
properties always return the same value regardless if the connection is
valid or not. Using the Receive(w/ Peek) method also does not work since it
waits for incoming data if the connection is valid. Any suggestions on how
to efficiently check the connection?

Thanks,
Bob L.


 
Reply With Quote
 
 
 
 
David Browne
Guest
Posts: n/a
 
      23rd Jul 2004

"Bob L." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, everyone,
>
> I am trying to test a client/server solution that uses the .NET Socket

class
> (blocking mode on the server). I need the server to be able to verify that

a
> socket is still valid in case the client app drops the connection (i.e.

the
> client app crashes). The Poll method and the Available and Connected
> properties always return the same value regardless if the connection is
> valid or not. Using the Receive(w/ Peek) method also does not work since

it
> waits for incoming data if the connection is valid. Any suggestions on how
> to efficiently check the connection?
>



Aparently there are only two ways to do this.

Build a periodic "ping" into your conversation protocol or use the
SO_KEEPALIVE socket option. The problem with the SO_KEEPALIVE option is
that the keepalive packets are sent, by default, only every two hours. This
interval is configured in the registry and is system-wide.

From
http://www.microsoft.com/windows2000..._implement.asp


HKEY_LOCAL_MACHINE
\SYSTEM
\CurrentControlSet
\Services:
\Tcpip
\Parameters

KeepAliveTime
Key: Tcpip\Parameters
Value Type: REG_DWORD—time in milliseconds
Valid Range: 1–0xFFFFFFFF
Default: 7,200,000 (two hours)
Description: The parameter controls how often TCP attempts to verify that an
idle connection is still intact by sending a keep-alive packet. If the
remote system is still reachable and functioning, it acknowledges the
keep-alive transmission. Keep-alive packets are not sent by default. This
feature may be enabled on a connection by an application.

David


 
Reply With Quote
 
Bob L.
Guest
Posts: n/a
 
      24th Jul 2004
David,

Thanks for the ideas. I was trying to avoid the "ping" idea since this
solution is primarily a one way conversation: the client asking the server
for information. However, every two hours for the keep alive is acceptable
in our case, since it is primarily for cleanup and freeing resources.

Thanks again,
Bob

"David Browne" <davidbaxterbrowne no potted (E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
>
> "Bob L." <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi, everyone,
> >
> > I am trying to test a client/server solution that uses the .NET Socket

> class
> > (blocking mode on the server). I need the server to be able to verify

that
> a
> > socket is still valid in case the client app drops the connection (i.e.

> the
> > client app crashes). The Poll method and the Available and Connected
> > properties always return the same value regardless if the connection is
> > valid or not. Using the Receive(w/ Peek) method also does not work since

> it
> > waits for incoming data if the connection is valid. Any suggestions on

how
> > to efficiently check the connection?
> >

>
>
> Aparently there are only two ways to do this.
>
> Build a periodic "ping" into your conversation protocol or use the
> SO_KEEPALIVE socket option. The problem with the SO_KEEPALIVE option is
> that the keepalive packets are sent, by default, only every two hours.

This
> interval is configured in the registry and is system-wide.
>
> From
>

http://www.microsoft.com/windows2000..._implement.asp
>
>
> HKEY_LOCAL_MACHINE
> \SYSTEM
> \CurrentControlSet
> \Services:
> \Tcpip
> \Parameters
>
> KeepAliveTime
> Key: Tcpip\Parameters
> Value Type: REG_DWORD-time in milliseconds
> Valid Range: 1-0xFFFFFFFF
> Default: 7,200,000 (two hours)
> Description: The parameter controls how often TCP attempts to verify that

an
> idle connection is still intact by sending a keep-alive packet. If the
> remote system is still reachable and functioning, it acknowledges the
> keep-alive transmission. Keep-alive packets are not sent by default. This
> feature may be enabled on a connection by an application.
>
> David
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      24th Jul 2004
"Bob L." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, everyone,
>
> I am trying to test a client/server solution that uses the .NET Socket

class
> (blocking mode on the server). I need the server to be able to verify that

a
> socket is still valid in case the client app drops the connection (i.e.

the
> client app crashes). The Poll method and the Available and Connected
> properties always return the same value regardless if the connection is
> valid or not. Using the Receive(w/ Peek) method also does not work since

it
> waits for incoming data if the connection is valid. Any suggestions on how
> to efficiently check the connection?


Why do you need to know the connection is open?

At any rate, about the only way to know that the connection is open is to
send something and then to get a response to what you sent. Sending on a
broken connection may succeed at first. Receiving on a broken connection may
also succeed. The only way to be sure is to send a "ping" message, including
a unique value, and then to receive a response which contains the same
unique value. That will tell you that the connection was open at the time
you sent the unique value.
--
John Saunders
johnwsaundersiii at hotmail


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception: A socket operation has encountered a dead network weird0 Microsoft C# .NET 11 13th Jul 2007 03:38 AM
Socket.BeginSendTo and Socket.BeginSendFrom on a single Socket instancefrom multiple threads Jonas Hei Microsoft Dot NET Framework 9 5th Jul 2005 03:27 AM
Dead gateway detection Mickey Thomas Windows XP Networking 2 8th Nov 2003 07:17 AM
Dead Gateway detection Jeremy Microsoft Windows 2000 Networking 1 30th Oct 2003 07:43 PM
Dead Gatway detection Jeremy Microsoft Windows 2000 Advanced Server 2 28th Oct 2003 12:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:32 PM.