Problem with binding of socket addresses

Eric Peterson epeterso at houligan.encore.com
Tue Dec 4 07:54:01 AEST 1990


I've encountered some odd behavior in trying to set up a simple
client-server system via sockets.  It appears to be that Internet
bindings are not readily reusable.  Here's a quick description of
what's going on ...

I'll start up the server process which creates a socket, binds itself
to an Internet address, then listens for incoming connections.  I'll
then start up the client which connects to the server.  Once the
connection is established, the client closes its socket and dies.  The
server sees the disconnection and closes its acceptor socket.  I can
then restart the server to wait for new connections.

However, the server occasionally hits a bug and core dumps or dies off
in some other way.  But it dies off and closes its end of the
connection before the client closes the other end.  When this occurs
and I attempt to restart the server, the bind() call fails with the
error "Address already in use".

Now, neither the client nor the server is running at the time I try to
restart the server, and there isn't a problem with address collisions
with another process.  As far as I can tell, nothing else is using
this address.  So why does bind() fail?

I've seen this occur on several different flavors of Unix, from SunOS
to Ultrix to System V variants with BSD extensions.  Anyone know why
this happens?  And is there any way to prevent this behavior?

Thanks in advance.

Eric
--
       Eric Peterson <> epeterson at encore.com <> uunet!encore!epeterson
   Encore Computer Corp. * Ft. Lauderdale, Florida * (305) 587-2900 x 5208
Why did Constantinople get the works? Gung'f abobql'f ohfvarff ohg gur Ghexf.



More information about the Comp.unix.programmer mailing list