Results 1 to 3 of 3
Hi , I am writing some application like file download through HTTP protocol. The application downloading file very fine as along as there was no disruption network cable. But when ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-27-2009 #1
- Join Date
- Jan 2007
TCP application resume after network cable disconnect.
I am writing some application like file download through HTTP
The application downloading file very fine as along as there was no
disruption network cable.
But when cable disrupting events like unplug and plug after some time,
i could not receive data.
i am using timed out mechanism to avoid blocking in recv() or send().
i was receiving errno as EWOULDBLOCK but i ignored it and keep on
receiving to proceed download further.
i have few more doubts :
i) i could observe the network time out error only once. but each recv
() expected to be returned time out error. is not it?
ii) After plugging the network cable there was no indication for data
Please help me how to resume the connection. after cable broken or
time out ?
Thanks in advance,
- 08-29-2009 #2
- Join Date
- Aug 2009
I don't know if it's possible from the application program. I've been using mobile IP to handle this kind of situation.
The issue is I guess the IP address may have disappeared or changed when the link is down, and TCP can no longer send data through the socket. You may want to check this.
- 06-01-2012 #3
- Join Date
- Oct 2010
an Inherent problem with TCP/IP sockets is that any network cables unplugged along the route from one side to the other will not cause a socket error. Conection breaks without any notification. To address this issue at the socket level, one recommended approach is to use TCP keepalive mechanism that can be used to detect NW cable disconnect. It requires one to enable TCP/IP networking in order to use it. You also need procfs support and sysctl support to be able to configure the kernel parameters at runtime.
In Linux system the following 3 system params needs to be overwritten with user defined values:
Here's how we would change the settings:
# echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time
# echo 20 > /proc/sys/net/ipv4/tcp_keepalive_intvl
# echo 10 > /proc/sys/net/ipv4/tcp_keepalive_probes
Code changes needed to support “keepalive”
Enable Tcp Keepalive with setsockopt function call
int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
After making the above changes and upon NW disconnect your Select() call shall return (after some timeout period) with a socket error message based on which you can take desired action.