Solved

Winsock and dropped connections.

Posted on 2000-03-15
4
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

734 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