setting  option SO_REUSEADDR, has a number of uses, one being that if
the listening gciserver is killed and there are still live connections,
a new server can be started. Without this option the system will return
error "address already in use". 

This condition is typically encountered as follows:

a) a listening server is started
b) a connection request arrives and a child process is spawned to handle
that client
c) the listening server terminates but the child continues to service
the client on the existing connection
d) then an attempt is made to restart the listening server (will fail
with address already in use due to client connection)

SO_REUSEADDR also allows two listening servers to be started for the
same port no, but specifying different ip addresses (if hosts has
mulitple addresses). However we can still only start one server for each
ip address available to the machine

I have never heard of the shutdown issue mentioned below. I have been
writing socket applications for a long time and use SO_REUSEADDR and
have never come across this issue.

There are some other uses for RO_REUSEADDR which are quite advanced.

Reason why close my not shutdown a socket.

If a parent process and child process have a socket handle open. In the
case of the parent forgetting to do a close on the socket handle after
an accept call, then there will be two references to the same socket.
When the close is called by the child then the open reference counter on
the socket will be decremented but the socket will not be shutdown (as
the parent still has it open). The socket will only be shutdown if the
parent closes the socket too. This is a common mistake. However if the
code is corrected and the parent does close the socket, then when the
child calls close on the socket, there is only one reference count to
the socket then a close will shutdown the socket too.

James


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Glen B
Sent: 25 February 2005 14:28
To: [email protected]
Subject: RE: [U2][UV] Forcing a port to close


 Nick,

  I looked this up in the socket guide and the syntax is correct. The
only real issue that can arise by enabling address re-use is
the slim possibility that partial data could be received into the socket
buffer, from the sockets that were never shutdown down
properly. This can lead to confusion in the application and/or the
socket subsystem. I've never had that issue occur, but the
possibility of the condition should be known.

Just for clarity in future reading, socket shutdown and close are not
synonymous.
Close refers only to the release of a file handle. A handle can be
closed and re-opened on the same socket address.
Shutdown refers to the releasing of the file handle and also the
addresses used by the socket.

Glen
http://picksource.com
http://mvdevcentral.com
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to