Re: Different tcp connect behaviour in 2.2.5 and 2.2.12

From: Ed Carp (erc@pobox.com)
Date: Fri May 12 2000 - 16:12:40 EST


Frank Reerink (frank.reerink@cmg.nl) writes:

> Hi All,
>
> I developed a client/server app that worked fine with kernel 2.2.5 but
> behaves not the way I want under kernel 2.2.12.
> My client connects to my server on port 5001 and the client does a local
> bind on port 6002 for that socket first, i.p. addresses are all localhost.
> The first connection works fine, but if I try to make another parallel
> connection then the connect (in the client) returns error 99, cannot assign
> requested address. Also after I disconnect the socket with shutdown(fd,2)
> and close(fd) then another connect returns the same error 99. Only after I
> wait some time (until netstat | grep 6002 gives nothing) the connect
> succeeds again.
> How can I get connects with local bind to work on 2.2.12?

After you do a close() on the socket, the socket doesn't go into CLOSE right
away, but goes into TIME_WAIT to make sure that any packets that were delayed
en route along the way are properly handled. I suspect that shutdown() wasn't
handled properly in 2.2.5 and it is in 2.2.12.

The error you're getting is EADDRNOTAVAIL, which would be normal if the socket
is in TIME_WAIT.

You might want to take a look at the UNIX Socket FAQ, which talks about how to
program client/server socket apps correctly. :)

--
Ed Carp, N7EKG  	erc@pobox.com		940/367-2744 cell phone
			http://www.pobox.com/~erc

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:21 EST