 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Frederico Pissarra Guest
|
Posted: Tue Sep 19, 2006 11:08 pm Post subject: TIdTCPServer TIME_WAIT problem |
|
|
I have 2 simple apps: One TCP Server (OnExecute below):
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var S: String;
begin
with AThread.Connection do
if Connected then
begin
S := ReadLn;
WriteLn(S);
Disconnect;
end;
end;
I'm testing this with telnet... it works perfectly but, when the server
disconnects and I ran "netstat -a -p tcp" I got this:
Proto Local Address Remote Address Stat
TCP localhost:10000 localhost:0 LISTENING
TCP localhost:10000 localhost:1217 TIME_WAIT
Well... I don't have the telnet application running at this point... and the
server app disconnected... why this TIME_WAIT entry? How can I get rid of
it?
[]s
Fred |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Sep 19, 2006 11:54 pm Post subject: Re: TIdTCPServer TIME_WAIT problem |
|
|
"Frederico Pissarra" <me (AT) nowhere (DOT) net> wrote in message
news:45103211 (AT) newsgroups (DOT) borland.com...
Get rid of that line, and use DisconnectSocket() instead of Disconnect():
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
S: String;
begin
with AThread.Connection do
begin
S := ReadLn;
WriteLn(S);
DisconnectSocket;
end;
end;
| Quote: | I'm testing this with telnet... it works perfectly but, when the server
disconnects and I ran "netstat -a -p tcp" I got this:
Proto Local Address Remote Address Stat
TCP localhost:10000 localhost:0 LISTENING
TCP localhost:10000 localhost:1217 TIME_WAIT
|
As you should be.
| Quote: | Well... I don't have the telnet application running at this point...
and the server app disconnected... why this TIME_WAIT entry?
|
When a socket is closed, the OS holds the connection open behind the scenes
for an extended period of time, usually 30-120 seconds, to ensure that any
stray packets for the connection get removed from the network.
| Quote: | How can I get rid of it?
|
You cannot.
Gambit |
|
| Back to top |
|
 |
Martin James Guest
|
Posted: Wed Sep 20, 2006 12:04 am Post subject: Re: TIdTCPServer TIME_WAIT problem |
|
|
| Quote: | Well... I don't have the telnet application running at this point... and the
server app disconnected... why this TIME_WAIT entry?
|
It is in the nature of communications that involve latency. When
something happens at one point, not all parties, data etc. get to know
about it for some time. This can cause problems. In TCP, after a
connection has been closed, there may still be data flowing around the
network associated with the now-closed connection. There could be
problems if the socket was re-opened immediately for another connection.
One way round this is to not recycle the socket until a sufficient time
has elapsed for all possible in-flight packets to have arrived and been
dumped. TCP does this.
How can I get rid of
You do not want to get rid of it. The default TIME_WAIT is, IIRC, 120
sec. After a couple minutes then, the TIME_WAIT state will disappear.
For special purposes, eg. load-testing servers, it can be useful to
reduce the timeout considerably. There is a registry entry for it:
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\TcpTimedWaitDelay
When connect/disconnect load-testing of my server, I set this at 30 secs
to prevent the test loading from running the system out of available
sockets.
Rgds,
Martin |
|
| Back to top |
|
 |
Frederico Pissarra Guest
|
Posted: Wed Sep 20, 2006 12:09 am Post subject: Re: TIdTCPServer TIME_WAIT problem |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> escreveu na mensagem
news:45103d88$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"Frederico Pissarra" <me (AT) nowhere (DOT) net> wrote in message
news:45103211 (AT) newsgroups (DOT) borland.com...
if Connected then
Get rid of that line, and use DisconnectSocket() instead of Disconnect():
|
Ok! :)
| Quote: | When a socket is closed, the OS holds the connection open behind the
scenes
for an extended period of time, usually 30-120 seconds, to ensure that any
stray packets for the connection get removed from the network.
How can I get rid of it?
You cannot.
|
Thank you, Remy....
One more question: Is this timeout value configurable?
[]s
Fred |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Sep 20, 2006 1:05 am Post subject: Re: TIdTCPServer TIME_WAIT problem |
|
|
"Frederico Pissarra" <me (AT) nowhere (DOT) net> wrote in message
news:45103211 (AT) newsgroups (DOT) borland.com...
| Quote: | TCP localhost:10000 localhost:1217 TIME_WAIT
|
Have a look at the following article for more details:
TCP TIME-WAIT Delay
http://msdn.microsoft.com/library/en-us/randz/protocol/tcp_time-wait_delay.asp
Gambit |
|
| Back to top |
|
 |
Frederico Pissarra Guest
|
Posted: Wed Sep 20, 2006 5:49 pm Post subject: Re: TIdTCPServer TIME_WAIT problem |
|
|
Thank you very much!! You helped a lot! :)
[]s
Fred |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|