"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