Networking Forums

Networking Forums > Computer Networking > Linux Networking > Socket Timeouts

Reply
Thread Tools Display Modes

Socket Timeouts

 
 
Dan N
Guest
Posts: n/a

 
      09-16-2005, 01:33 AM

I have a server application with a tcp socket listening for incoming
connections. The client application is on a tablet that connects to the
network via wifi. Assume that the client opens a connection to the
server and then is taken out of range.

The server then writes some data to the socket. The tcp-ip stack will
repeatedly send the data packet to the client, hoping to get a tcp ack
back. How long will it resend the packet before it abandons the process?
I know that it resends at increasingly longer intervals, but how long are
those intervals?

What I'm aiming to accomplish is seamless communications between the
client and the server. The tablet could be out of range for quite some
time. When it comes back into range, I want to make sure that it gets
its data. At what point does the server application have to consider
session invalid and perform remedial action?

Dan
 
Reply With Quote
 
 
 
 
David Schwartz
Guest
Posts: n/a

 
      09-16-2005, 03:59 AM

"Dan N" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) ldomain...

> I have a server application with a tcp socket listening for incoming
> connections. The client application is on a tablet that connects to the
> network via wifi. Assume that the client opens a connection to the
> server and then is taken out of range.


Okay.

> The server then writes some data to the socket. The tcp-ip stack will
> repeatedly send the data packet to the client, hoping to get a tcp ack
> back.


Correct.

> How long will it resend the packet before it abandons the process?


Until it makes the determination that communication is impossible.

> I know that it resends at increasingly longer intervals, but how long are
> those intervals?


The application should not depend upon the intervals being any
particular value. The stack will tell you when it has given up.

> What I'm aiming to accomplish is seamless communications between the
> client and the server. The tablet could be out of range for quite some
> time. When it comes back into range, I want to make sure that it gets
> its data. At what point does the server application have to consider
> session invalid and perform remedial action?


When the TCP/IP stack says the connection has broken. Just make sure
that both sides periodically send some data or one side sends data and the
other side times out. This will guarantee you timely detection of
communication failure. When a TCP link breaks, you can try to re-establish
the link by creating a new link.

You have to do the following things:

1) Ensure timely detection of link loss. This means that each side has
to be either sending data or waiting a finite amount of time before it sends
data or times out.

2) Attempt to re-estalibish a broken connection. That is, once you get a
report from the stack that the connection has broken, one end (at least)
must attempt to re-establish a connection.

3) Resume context once a new connection is made. This depends upon
exactly what you're doing, but you need to figure out where you were and
keep going once the new TCP connection is operational.

DS


 
Reply With Quote
 
Dan N
Guest
Posts: n/a

 
      09-16-2005, 05:28 AM
On Thu, 15 Sep 2005 20:59:36 -0700, David Schwartz wrote:

>The stack will tell you when it has given up.


How does it do so? When the client closes the socket, the server gets a
read with length zero. Is this what happens when the stack gives up?

Dan


 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      09-16-2005, 11:53 AM

"Dan N" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) ldomain...

> On Thu, 15 Sep 2005 20:59:36 -0700, David Schwartz wrote:


>>The stack will tell you when it has given up.


> How does it do so? When the client closes the socket, the server gets a
> read with length zero. Is this what happens when the stack gives up?


No, that's what happens when the client closes the socket. When the
stack gives up, read will return -1 and errno will tell you what the error
is.

DS


 
Reply With Quote
 
Dan N
Guest
Posts: n/a

 
      09-17-2005, 01:53 AM
On Fri, 16 Sep 2005 04:53:22 -0700, David Schwartz wrote:

> When the
> stack gives up, read will return -1 and errno will tell you what the error
> is.


Thanks Dave, that's the missing bit of information that I needed. It's
not immediately obvious that a write failure causes an error on the read.

Dan
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      09-18-2005, 11:34 AM

"Dan N" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) ldomain...

> On Fri, 16 Sep 2005 04:53:22 -0700, David Schwartz wrote:


>> When the
>> stack gives up, read will return -1 and errno will tell you what the
>> error
>> is.


> Thanks Dave, that's the missing bit of information that I needed. It's
> not immediately obvious that a write failure causes an error on the read.


Nope, it's not immediately obvious. But if you think about it, if the
connection breaks, a 'read' cannot succeed.

DS


 
Reply With Quote
 
Dan N
Guest
Posts: n/a

 
      09-19-2005, 02:14 AM
On Sun, 18 Sep 2005 04:34:44 -0700, David Schwartz wrote:

> Nope, it's not immediately obvious. But if you think about it, if the
> connection breaks, a 'read' cannot succeed.


Or, to find the status of the connection, you have to
'read' it.

Dan

 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      09-19-2005, 06:31 PM

"Dan N" <(E-Mail Removed)> wrote in message
news(E-Mail Removed) ldomain...

> On Sun, 18 Sep 2005 04:34:44 -0700, David Schwartz wrote:


>> Nope, it's not immediately obvious. But if you think about it, if the
>> connection breaks, a 'read' cannot succeed.


> Or, to find the status of the connection, you have to
> 'read' it.


You can use 'getsockopt(SO_ERROR)'. But that has its own issues.

DS


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cluster IP timeouts? CANews Windows Networking 2 07-01-2010 10:48 PM
TCP Timeouts CANews Windows Networking 0 05-08-2010 04:36 AM
TCP timeouts Justin Todd Linux Networking 1 08-10-2005 09:52 PM
Linux (RH8) Socket Timeouts Otto Blomqvist Linux Networking 1 09-20-2004 01:37 PM
Timeouts from PC T Conti Wireless Internet 0 12-04-2003 04:16 PM



1 2 3 4 5 6 7 8 9 10 11