Re: Likely cause of EAGAIN in connect() in 2.2.8??

Andi Kleen (ak@muc.de)
Thu, 13 May 1999 09:02:14 +0200


In muc.lists.linux-kernel, you wrote:
>
>The EAGAIN error code is not a documented return code from connect() in the
>manual pages on my Debian Linux 2.1 system. Either this is a documentation
>problem or a kernel problem in that it is ever returned, and if it is simply
>a documentation problem, I would still like to know how to prevent my program
>from getting it.

It is documented in netman now.

>
>(and I know it's not a library issue - I don't use any libraries :-)
>
>The situation: very small optimized network scanner (8k/process memory image,
>"statically linked"[1], when I start working on it again I hope to get this
>down to 4kb as it is actually using around 2kb and the rest is since I can't
>get it to use that on less than 2 pages), forks and does ~250 non-blocking
>connects per process and then select()s on them. The only known kernel it
>works with is 2.0.36, due to route cache bugs in earlier versions and this
>EAGAIN issue I'm hitting now in 2.2.8.
>
>Here's a sample from strace (after a stream of successful connect()s):
>
>[pid 798] connect(23, {sin_family=AF_INET, sin_port=htons(25),
> sin_addr=inet_addr("130.95.5.23")}, 16) = -1 EAGAIN
> (Resource temporarily unavailable)

This happens when you run out of local ports. Earlier 2.2 had some leaks
in this regard, but they should be fixed in 2.2.8. You can try to increase
the local port range in /proc/sys/net/ipv4/ip_local_port_range.
Setting SO_REUSEADDR on connected sockets may help too.

-A.

-
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/