Re: problem in accept()

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Well, you can debug it and see that it doesn't, or you can write your own
test program to illustrate the behaviour. In either case, be aware that the
Windows TCP stack has an optimization for connections via the loopback
adapter so make sure to test with a remote host.



Remember that a socket in the listening state is not ever connected so the
local binding becomes unused as soon as the bound socket is closed without
the need to wait for a remote host to be in a safe state. This is the
difference between closing a socket and closing a connection.


"boris" <somewhere@xxxxxxxxxxx> wrote in message
news:49ee0a56$0$1672$742ec2ed@xxxxxxxxxxxxxxxxx
Your so called "simple test" isn't worth much - how do you know that IIS
doesn't use SO_REUSEADDR option?

QUOTE
SO_REUSEADDR

By default, a socket cannot be bound (see bind) to a local address that is
already in use.
...
<<<QUOTE
http://msdn.microsoft.com/en-us/library/ms740476(VS.85).aspx

QUOTE
The TIME_WAIT state is also called 2MSL state...Given the MSL value for an
implementation, the rule is: when TCP performs an active close, and sends
the final ACK, the connection must stay in the TIME_WAIT state for twice
the MSL...Another effect of this 2MSL wait is that while the TCP
connection is in the 2MSL wait, the socket pair defining that connection
(client IP address, client port number, server IP address, and server port
number) cannot be reused. The connection can only be reused when the 2MSL
wait is over.Unfortunately most implementations (i.e., the Berkley-derived
ones) impose a more stringent constraint. By default a local port number
cannot be reused while that port number is the local port number of a
socket pair that is in the 2MSL wait.
<<<QUOTE
TCP/IP Illustrated by Richard Stevens (volume 1, page 242)

Boris
"m" <m@xxx> wrote in message news:e4rc1HowJHA.5516@xxxxxxxxxxxxxxxxxxxxxxx
This is complete nonsense and has nothing to do with the OP's problem.
The OP needs to create his socket as OVERLAPED and put the listen loop in
a thread that aborts when the socket is closed (from the main or another
thread). This will allow his application to _shutdown_ properly.

A very simple test should sufice to convince yourself that a bound
listening socket does not exhibit the behaviour you content: initiate
multiple connections to IIS (or your webserver of choice) and restart it.
Use netstat or TCPView to watch the sockets on the server.

"boris" <somewhere@xxxxxxxxxxx> wrote in message
news:49ed3169$0$1655$742ec2ed@xxxxxxxxxxxxxxxxx
To make it more clear: when server TCP socket is closed, it gets into
2MSL state. Default timeout value for that state is 2 minutes. As in OP
scenario: he closed server app and then restarted it. Until 2 minutes
timeout expires, the server app will not be able to bind to same port
(unless SO_REUSEADDR option was specified).

Boris
"boris" <somewhere@xxxxxxxxxxx> wrote in message
news:49ed2f51$0$1634$742ec2ed@xxxxxxxxxxxxxxxxx
Wrong.
Just read a book on TCP/IP.

Boris

"Remy Lebeau" <no.spam@xxxxxxxxxxx> wrote in message
news:eP8sBjhwJHA.528@xxxxxxxxxxxxxxxxxxxxxxx

"boris" <somewhere@xxxxxxxxxxx> wrote in message
news:49e8433b$0$1606$742ec2ed@xxxxxxxxxxxxxxxxx

Most likely, your socket can't bind to same port again.

This is not a binding issue. This is a shutdown issue.

--
Remy Lebeau (TeamB)








.



Relevant Pages

  • Re: Still cant connect to RWW or OWA remotely
    ... it certainly appears to be something about the SBS configuration. ... Meridian.local Ethernet adapter Local Area Connection: ... Windows SMALL BUSINESS SERVER 2003 Windows IP Configuration ... 192.168.254.254) directly to a port on the router and then ...
    (microsoft.public.windows.server.sbs)
  • Re: Still cant connect to RWW or OWA remotely
    ... it certainly appears to be something about the SBS configuration. ... Meridian.local Ethernet adapter Local Area Connection: ... Windows SMALL BUSINESS SERVER 2003 Windows IP Configuration ... 192.168.254.254) directly to a port on the router and then ...
    (microsoft.public.windows.server.sbs)
  • RE: VBscript Error on SBS2k3
    ... DHCP Server turned of SonicWALL with VPN Pass through request for IP to ... the problem should be caused by the 4125 port. ... > | Accessories and Communications and Remote Desktop Connection? ... > | 2.In Internet Explorer on the workstation you are connecting from, ...
    (microsoft.public.windows.server.sbs)
  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ... /// Required designer variable. ...
    (microsoft.public.win32.programmer.networks)
  • Re: interfaces lo:1 lo:2 lo:3? (for remote ssh tunnels)
    ... That's the problem tunneling (port forwarding) solves. ... >>can't get past the client firewall. ... > I don't understand why the server would be making the ... server initiates another connection to the client -- in this ...
    (Debian-User)