Upper bound on no. of sockets

Yudong Tian yudong at hsb.gsfc.nasa.gov
Tue Sep 30 15:56:41 EDT 2003


The number of sockets a process can open is limited by
the number of file descriptors (fds). Type "ulimit -n"
under bash to get this number, which usually 1024 by
default.

You can increase this number if you wish. Google
"increase Linux file descriptors" you will find many examples,
like this one:
http://support.zeus.com/faq/zws/v4/entries/os/linuxfd.html

If you want to be really sure, you can compile and run the
following c program to get the number, which is the output
plus 3 (stdout, stdin and stderr):

/*
# test how many fd you have
$Id$
*/

int main(int argc, char *argv[])
{

 int i = 0;

 while( tmpfile()){ i++; }
 printf("Your free fds: %d\n", i);

}

/*** end of program ***/

If you are running a TCP server and want to test how many clients
that server can support, you can run the following perl program
to test:

#!/usr/bin/perl
# Test the max number of tcp connections a server can support
# $Id: testMaxCon.pl,v 1.1 2003/06/23 19:10:41 yudong Exp yudong $
# usage: testMaxCon.pl IP port

use IO::Socket::INET;

@ARGV == 2 or die "Usage: testMaxCon.pl svr_ip svr_port\n";

my ($ip, $port) = @ARGV;

my $i = 0;

do {
  $i++;
  $socket[$i] = IO::Socket::INET->new(PeerAddr => $ip,
                                      PeerPort => $port,
                                      Proto => "tcp",
                                      Timeout => 6,
                                      Type => SOCK_STREAM);
} while ($socket[$i]);

print "Max TCP connections supported for this client: ", $i-1, "\n";
## end of program

  Of course for this test you have to make sure you have more fds
to use than the server.

Hope that helps.

Yudong
------------------------------------------------------------
Falun Dafa: The Tao of Meditation (http://www.falundafa.org)
------------------------------------------------------------
Yudong Tian, Ph.D.  NASA/GSFC  (301) 286-2275


> -----Original Message-----
> From: beowulf-admin at scyld.com [mailto:beowulf-admin at scyld.com]On Behalf
> Of Balaji Rangasamy
> Sent: Tuesday, September 30, 2003 12:44 AM
> To: beowulf at beowulf.org
> Subject: Upper bound on no. of sockets
>
>
> Hi,
> Is there an upper bound on the number of sockets that can be created by a
> process? If there is one, is the limitation enforced by OS? And what other
> factors does it depend on? Can you please be specific on the numbers for
> different OS (RH Linux 7.2) ?
> Thank you very much,
> Balaji.
>
>
> _______________________________________________
> Beowulf mailing list, Beowulf at beowulf.org
> To change your subscription (digest mode or unsubscribe) visit
> http://www.beowulf.org/mailman/listinfo/beowulf

_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list