Find the answer to your Linux question:
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.
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Location
    India
    Posts
    10

    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 ?

    Thanks in advance,
    Ganesh

  2. #2
    Just Joined!
    Join Date
    Aug 2009
    Location
    Germany
    Posts
    12
    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.

  3. #3
    Just Joined!
    Join Date
    Oct 2010
    Posts
    6
    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

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

    regards,
    Hussain

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •