[comp.sys.sun] tcp/ip: address already in use ?

DHEINZER%ESOC.BITNET@cunyvm.cuny.edu (Danielle Heinzer) (06/28/91)

1.
From the Network Programming Manual (for sunos 4.1 on page 310-311):

"In certain cases the algorithm used by the system in selecting port numbers
is unsuitable for an application... the system would disallow binding the
same local address and port number to a socket if a previous data connection's
socket still existed... an option call must be performed prior to the address
binding:

int on = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on);
bind(s, (struct sockaddr *) &sin, sizeof sin);

With the above call, local addresses may be bound that are already in use.
This does not violate the uniqueness requirement as the system still checks at
connect time to be sure any other sockets with the same local address and
port do not have the same foreign address and port. If the association exists,
the error EADDRINUSE is returned."

The setting of this option on a TCP/IP socket did not show any difference.
Can you tell me what this option is for?

2.
Following problem:
o A server task listens (X simultaneous sockets are allowed),
o nine sockets are already connected with client tasks,
o the server task is abborted by CTRL-C.

Another program tries to bind to the local address used by the preceding
server and gets error EADDRINUSE.

"netstat" shows no TCP utilisation of that port.

Any idea? Is it a sunos problem not releasing properly the sockets on abbort?

note: this does not happen if only one client was connected at the time the
abbort happens. this does happen only sporadically.

I did not report this problem to Sun Hotline because I am not able to provide
them with a 70 source lines test program...

Any help will be wellcome.

regards,
Danielle Heinzer
ESA Computer Department/Computer Services
European Space Operations Centre
Robert-Bosch-str. 5
6100 Darmstadt
West-Germany
Tel int : +49-6151-90-2540
Fax int : +49-6151-90-495
Bitnet  : dheinzer@esoc
Uucp    : unido!esoc.bitnet!dheinzer