[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [Subclipse-dev] Excessive use of TCP sockets

From: Karen Tracey <kmtracey_at_gmail.com>
Date: 2007-06-15 04:45:46 CEST

At 02:41 PM 6/14/2007, Alexander Kitaev wrote:
>Hello,
>
>Thank you for your note, Karen. I fully agree with that, at least I
>read exactly this while investigating what does TIME_WAIT state mean.
>
>However, as far as I know there is an OS limit on amount of sockets
>being in TIME_WAIT state. Am I wrong with that?

I don't know. What OS? My background is in Berkeley-based TCP/IP
implementations and there certainly was no imposed limit on number of
connections in TIME_WAIT state there. If an OS is trying to enforce
a concurrent connection limit and counts TIME_WAIT connections
against that limit I'd argue that OS was broken -- TIME_WAIT
connections are essentially closed. TCP just holds them around a bit
to protect applications from stray data belonging to that connection
interfering with subsequent connections.

Now, a TIME_WAIT connection is possibly tying up a port number, if
you're seeing these on the client side (that is, the side that
connects to a well-know port). In that case the local port number
will usually be dynamically chosen from a range of several thousand,
and it won't be re-used until the old connection in TIME_WAIT goes
away. Is this the limit you are concerned about...running out of
port numbers in the dynamically-assignable range?

>I tried different combinations of Socket options and found out that
>on Windows with JDK 1.4.2 setting SO_LINGER to "0" makes socket
>spend no time in TIME_WAIT state. Any other values makes socket be
>in TIME_WAIT for default time (about 60 seconds). I read that
>setting SO_LINGER to 0 means that socket will be closed "forcefully"
>and some data being sent to the server may be lost, but in
>Subversion client socket is closed only when data is received from
>the server and there is no more data to send or read. I hope it is
>safe to set SO_LIGNER to 0 in that case.

This is only safe if at the application level you have some
confirmation that the other side has already received the last data
you sent. It sounds like that may be the case for you. You send a
request and get a response -- clearly the server must have received
your request in order to send the response, and I gather you know
when you have received the complete response. It doesn't seem that
SO_LINGER with timeout 0 would cause any harm in this case. In cases
where you aren't already sure at the application level that the other
side has received all the data you've sent, though, it's not safe.

Karen

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subclipse.tigris.org
For additional commands, e-mail: dev-help@subclipse.tigris.org
Received on Fri Jun 15 04:46:05 2007

This is an archived mail posted to the Subclipse Dev mailing list.