473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 16886
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Steven Van Dyke | last post by:
Hi I need a code snippet to determine if my computer is connected to a network or not. There's probably a System.Net function for it, but I cannot find it. Thanks, Steve
1
by: Sparky | last post by:
Hi I was wondering if someone can please enlighten me as to the best and most approved way to connect and disconnect network drives in vb.net. I have been using Mpr.dll API calls such as...
13
by: Shailesh Humbad | last post by:
Here is an advanced PHP question. Can anyone think of a way to detect the number of bytes written to output when a script is aborted? I am sending a large file to the client, and I want to record...
0
by: serban.lascu | last post by:
Hello! I have an application using LogonUser for authentification, running under XP SP2. LogonUser answers after a very long time (30 to 90 seconds) in the cases above: - I log on to Windows...
15
by: =?Utf-8?B?TVNU?= | last post by:
To demonstrate my problem, I have a very simple VB Windows application. It has a text box that is used to display a counter, a button to reset the counter, and a timer that increments the counter...
5
RevBooter
by: RevBooter | last post by:
hello all... got a bit of an issue going. i recently purchased a new laptop running vista, everything running swell. i also purchased a new router, as the router given to me by bt was not smart...
6
by: afaichun | last post by:
Hi, I have the following situation. When I unplugged the network cable from a running ethernet card in a Linux box, there has no sign telling me the cable is unplugged from the system perspective...
14
by: litusahoo | last post by:
Hi All, I have a lenovo 3000G/410 notebook ,yesterday and day before yesterday i was surfing the net using it and it was running for more than 36 works continously.After that when i unplugged the...
0
by: Ontrace | last post by:
hello, I have Problem with Client Server Application when I unplug the client network cable, the server still read the network stream what function should I use to make server detect that the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.