weird problem with connect()

Vedad Kajtaz (vk@mankind.net)
Thu, 23 Sep 1999 06:11:04 +0200


Hello,

i'm testing a network library that uses select() call, and that is
supposed to be
able to handle about 5000 simultaneous connections (TCP) - don't ask why
:-)
I wrote two programs, the server one that is accepting connections on
local port (7889 fyi) and
echoes back anything received on a socket, and a client that creates 10
sockets per seconds, connects,
and then sens a small packet (4 bytes) every second .

At the beginning, client was dumping core when it came to 1039th socket,
because of fd_sets being too small.
i've changed __FD_SETSIZE to 8192 in /usr/include/bits/select.h,
recompiled my app, and it worked fine...
... until the 3977th socket, where, on client side, connect fails.
strace output follows:

socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3979
ioctl(3979, FIONBIO, [1]) = 0
setsockopt(3979, SOL_SOCKET, SO_OOBINLINE, [1], 4) = 0
connect(3979, {sin_family=AF_INET, sin_port=htons(7889),
sin_addr=inet_addr("192.168.1.19")}, 16) = -1 EAGAIN (Resou
rce temporarily unavailable)
write(1, "->Created() failed (FALSE), errc"..., 38) = 38
write(1, "Retrying in next frame...\n", 26) = 26
close(3979) = 0

as printed on stdout, i try the same thing (socket(), putting in
nonblocking mode and connect()-ing) every
second, and it always fails. The previously created sockets and
connections continue working ok (all
client socks send data successfully, all server socks receive it and
resend it).
(NOTE: my lib expect connect() to return either 0 (happens rarely on
linux, always!? on freebsd, never!? on win32, when connecting to
localhost), or -1 with errno == EINPROGRESS)

The kernel is brand new 2.2.12 with raid patch applied (the one for
2.2.11 but mingo stated on
linux-raid that it's ok for 2.2.12), and system has been tuned as
follows:

[root@ganja /]# cd /proc/sys/fs/
[root@ganja fs]# cat file-max
32768
[root@ganja fs]# cat inode-max
131072
[root@ganja fs]# ulimit -n
32768

The system is a pII 450 with 128MB sdram and 512Mb swap partition on a
scsi disk.
Also, except server and client process', getty's , crond and inetd,
nothing was running on the box while testing.

I will, of course, provide futher information if requested.
Please help!

Thanks,
-- Vedad Kajtaz

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