472,096 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

How to detect network cable disconnection

Hi all,
i have TCP client server application written in C# using async
socket methods, eg BeginReceive(), BeginEnd() etc

server is continuesly running in the background, client connect to
server and recives data from server.
If server application shuts down client immedeatly recieves
disconnection or exception, but im not able to detect if some body
removed network cable of node , where server is running.
Client continuesly waits for data from server

Also netstat command shows the client in ESTABLISED state.

How to handle this situation.
Nov 16 '05 #1
5 16648
Hi Vijay,

There's a subsystem in Windows called System Notification Services. You can
get events such as "Network cable disconnected" from there. Please consult
MSDN on System Notification Services API.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Vijay" <vi**********@yahoo.com> wrote in message
news:a6**************************@posting.google.c om...
Hi all,
i have TCP client server application written in C# using async
socket methods, eg BeginReceive(), BeginEnd() etc

server is continuesly running in the background, client connect to
server and recives data from server.
If server application shuts down client immedeatly recieves
disconnection or exception, but im not able to detect if some body
removed network cable of node , where server is running.
Client continuesly waits for data from server

Also netstat command shows the client in ESTABLISED state.

How to handle this situation.


Nov 16 '05 #2
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:<#L*************@TK2MSFTNGP11.phx.gbl>...
Hi Vijay,

There's a subsystem in Windows called System Notification Services. You can
get events such as "Network cable disconnected" from there. Please consult
MSDN on System Notification Services API.
The problem is client and server are running on two different nodes,
say A and B respectively.
they are connected and TCP connection and sockets are in ESTABLISHED
state

suppose i disconnect the node b where server is running , How can can
i get notification in CLient, because client node is still connected
to network.

when i see state of client using netstate it shows ESTABLISED state.
--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Vijay" <vi**********@yahoo.com> wrote in message
news:a6**************************@posting.google.c om...
Hi all,
i have TCP client server application written in C# using async
socket methods, eg BeginReceive(), BeginEnd() etc

server is continuesly running in the background, client connect to
server and recives data from server.
If server application shuts down client immedeatly recieves
disconnection or exception, but im not able to detect if some body
removed network cable of node , where server is running.
Client continuesly waits for data from server

Also netstat command shows the client in ESTABLISED state.

How to handle this situation.

Nov 16 '05 #3
On 29 Jul 2004 22:02:10 -0700, Vijay <vi**********@yahoo.com> wrote:
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com>
wrote in message news:<#L*************@TK2MSFTNGP11.phx.gbl>...
Hi Vijay,

There's a subsystem in Windows called System Notification Services. You
can
get events such as "Network cable disconnected" from there. Please
consult
MSDN on System Notification Services API.

The problem is client and server are running on two different nodes,
say A and B respectively.
they are connected and TCP connection and sockets are in ESTABLISHED
state

suppose i disconnect the node b where server is running , How can can
i get notification in CLient, because client node is still connected
to network.

when i see state of client using netstate it shows ESTABLISED state.


you can't get a notification immediately because once a tcp/ip connection
is established it is valid until it is closed explicitly;
there is one way to determine whether both hosts are still alive: set the
keep-alive option on the socket:

bool enable;
int opt = (enable ? ~0: 0);
setsockopt(so, SOL_SOCKET, SO_KEEPALIVE, (char*)&opt,
(socklen_t)sizeof(opt));

every 2hours (i think this is the default) there is sent out a keep-alive
packet to determine whether the remote host is still there.
--
klaus triendl
Nov 16 '05 #4

"Vijay" <vi**********@yahoo.com> wrote in message
news:a6**************************@posting.google.c om...
Hi all,
i have TCP client server application written in C# using async
socket methods, eg BeginReceive(), BeginEnd() etc

server is continuesly running in the background, client connect to
server and recives data from server.
If server application shuts down client immedeatly recieves
disconnection or exception, but im not able to detect if some body
removed network cable of node , where server is running.
Client continuesly waits for data from server

Also netstat command shows the client in ESTABLISED state.

How to handle this situation.


================================================

The following may or may not suit your needs -

From "Media Sense" (W2K+) topic on MSDN:
"Media sense support allows the protocol stack to react to events and remove
stale parameters. For example, if a Windows 2000 computer is unplugged from
the network (assuming the network adapter supports Media Sense), after a
damping period of 20 seconds, TCP/IP invalidates the parameters associated
with the network that has been disconnected. The IP address(es) no longer
allow sends, and any routes associated with the interface are invalidated.

If an application is bound to a socket that is using an address that is
invalidated, it should handle the event and recover in a graceful way, such
as attempting to use another IP address on the system or notifying the user
of the disconnect."

See also MSDN topics RestoreMediaSense and DisableMediaSense.
--
Regards,

Jim Allison
jw*********@digitalcollimation.com
(de-mung by removing '.1')


Nov 16 '05 #5
That because client do recv() it receive immediately error and server can
receive it only after some operation
Arkady

"Vijay" <vi**********@yahoo.com> wrote in message
news:a6**************************@posting.google.c om...
Hi all,
i have TCP client server application written in C# using async
socket methods, eg BeginReceive(), BeginEnd() etc

server is continuesly running in the background, client connect to
server and recives data from server.
If server application shuts down client immedeatly recieves
disconnection or exception, but im not able to detect if some body
removed network cable of node , where server is running.
Client continuesly waits for data from server

Also netstat command shows the client in ESTABLISED state.

How to handle this situation.

Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Steven Van Dyke | last post: by
13 posts views Thread by Shailesh Humbad | last post: by
reply views Thread by serban.lascu | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.