Solved

Winsock and dropped connections.

Posted on 2000-03-15
4
204 Views
Last Modified: 2010-04-10
How can my client application detect that the connection to a server device is gone/lost, 'network cable is removed', before i send data with the send function?

0
Comment
Question by:Wolfie320
  • 3
4 Comments
 

Expert Comment

by:benny_czarny
ID: 2621663
I suppose it is a tcp connection ?

and regular sockets ( not a class )
? under NT ?
visual c++ ?

 
0
 
LVL 3

Accepted Solution

by:
ufolk123 earned 100 total points
ID: 2622107
Hi Wolfie320,

In standard socket interface it is not possible to find out the physical connection link breakup as TCP is a logical link so even if physical link is dissconnected and re-established quickly there should be no -problem for a slow user applicaiton.
Actually the physical link down can only be found probably after next call as send() does not check for any physical transfer .it just puts the data in local buffers and return.Only thing here which helps to detect physical connection to some extent is SO_KEEPALIVE option.Please check the man pages for setsockopt() for this.This will probe the link by sending regular packets over the network event when there is no actual data transfer so you you will be able to detect the network down problem.
Or in other case,You will only know when TCP really transfers the data, this may happen after your send and may be 3-4 more send after that .There is no way to force TCP to flush data across the net to identify this problem.

If you have specific doubts please get back.
0
 

Expert Comment

by:benny_czarny
ID: 2622126
the tcp stack sends a keep alive packet from time to time
you can control that via sessionKeepalive registry param
to increase resolution you'ld probably need to decrease the keep alive intervals

0
 

Expert Comment

by:benny_czarny
ID: 2622129
opps I did not see your comment
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now