Winsock do not free port after close listen-socket

Winsock do not free port after close listen-socket

Post by Gunther Matzaiti » Wed, 15 Dec 1999 04:00:00



Hello,

i have wrote a FTP-Server at Delphi 5 and now i have the problem, that after
passiv dataconnection the socket will be shutdown and close the winsock port
is still in use. Where it coming from? And how could i close the port? I
Socket used in non Bolcking mode.

Thanks Gunther

 
 
 

Winsock do not free port after close listen-socket

Post by Dror Harar » Wed, 15 Dec 1999 04:00:00


When a you close a socket, the TCP/IP protocol (rfc 793) mandates that the
port will be kept out of circulation for some period of time. During that
time, if you run NETSTAT, you will see that socket in the TIME_WAIT state.
After a few minutes, the port should get freed. This is a safety mechanism
in TCP/IP designed to avoid getting ghost data from a previous session. You
main want to try the REUSEADDR socket option to force the reuse of the port
before it gets freed.

/d


Quote:> Hello,

> i have wrote a FTP-Server at Delphi 5 and now i have the problem, that
after
> passiv dataconnection the socket will be shutdown and close the winsock
port
> is still in use. Where it coming from? And how could i close the port? I
> Socket used in non Bolcking mode.

> Thanks Gunther


 
 
 

1. winsock newbie - effects of not closing sockets

Hello,

Does anyone know what the effects are of opening a socket, i.e. when
performing a ping, and never closing the socket.  My app does this every
minute.  Would the app just hang or would it crash or neither.
It is the same socket each time ... I am trying to implement a ping.  Here's
the code I use for the socket connection ( it's in C++ and  the parameters
are defined in winsock.h ):

            socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)

It doesn't return any error and I can see that I'm connecting alot of times
and I have since corrected this.  But I'm wondering if the crashes and hangs
I have been having in my app is because of this.  Would opening
hundreds of sockets cause the system to get bouged down ( take up
system resources ) or even crash the app??

Thanks

2. Maestro modem info wanted

3. Closing a listening socket

4. memory map for als cp/m card

5. Shutdown Listening socket (win socket 2 - vs 1)

6. Reading a .res file...

7. listen(socket, 1) then socket cannot be shutdown

8. Backdoors! - Hottie32a.jpg [1/1]

9. NT socket stack bug: Listening socket stops notification?

10. Can one programmatically close a port left open by a socket (app crashed)?

11. how to detect client remotely closing socket with IO Completion Ports, WSA ASync calls?

12. Socket closing and not returning any error...

13. closesocket() on inherited sockets under Windows 95 not giving close notification?