Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

Winsock and dropped connections.

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
Wolfie320
Asked:
Wolfie320
  • 3
1 Solution
 
benny_czarnyCommented:
I suppose it is a tcp connection ?

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

 
0
 
ufolk123Commented:
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
 
benny_czarnyCommented:
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
 
benny_czarnyCommented:
opps I did not see your comment
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now