If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below. ** If you are logged in, most ads will not be displayed. **

TCP application resume after network cable disconnect.

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 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
receive.

Please help me how to resume the connection. after cable broken or
time out ?

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:
tcp_keepalive_time (/proc/sys/net/ipv4/tcp_keepalive_time)
tcp_keepalive_intvl /proc/sys/net/ipv4/tcp_keepalive_intvl)
tcp_keepalive_probes /proc/sys/net/ipv4/tcp_keepalive_probes

Here's how we would change the settings:
# echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time