*BSD News Article 58839


Return to BSD News archive

Newsgroups: comp.unix.bsd.netbsd.misc
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!news.kei.com!newsfeed.internetmci.com!in2.uu.net!deshaw.com!christos
From: christos@deshaw.com (Christos Zoulas)
Subject: Re: How to run a process in NetBSD with more than 20 sockets
Message-ID: <DL1p2G.G70@deshaw.com>
Sender: usenet@deshaw.com
Nntp-Posting-Host: es2
Organization: D. E. Shaw & Co.
References: <4cqk7e$1gi@nntp.Stanford.EDU> <4d31el$svk@rc1.vub.ac.be>
Date: Fri, 12 Jan 1996 01:49:28 GMT
Lines: 40

In article <4d31el$svk@rc1.vub.ac.be> mcoevoet@vub.ac.be (Frederik Bultot) writes:
>Peter Tam (pct@lyra.stanford.edu) wrote:
>: There is a limit of file descriptors table size in NetBSD, it is 20 I guess.
>: I think by getfdtablesize() I can get it. The problem is I would like to
>: run up at least 100 sockets/file descriptors in one process, so that it
>: can serve at least a hundred tcp connections.
>
>: I tried, but the software crashed with "Broken Pipe" after the 19-22 sockets
>: get connected. That is not going to help my requirements.
>
>: Anyone knows where in kernel code that spec the file descriptor table size,
>: and may be by hacking it I can get NetBSD to do the thing I want it to do.
>
>
>
>Go in the /usr/include dir, there
>you'll find (probably) in stdio.h
>
>#define _NFILE  100     /* initial number of streams */
>#define FOPEN_MAX       _NFILE
>
>(This is from an sgi system, but they're all the same,
>except when you expect too much similarity.)
>You simply adapt this number to your wishes.

Bzzt...

As the comment above indicates in the code sample you provide this constant
is used to determine the initial number of streams allocated in the array
stdio keeps internally [_NFILE], while the second constant indicates the
number of files that a user can open safely with the default system resource
allocation.

The limit on file descriptors can be altered with the ulimit (sh) or
limit and unlimit commands (csh). Programmatically you can do the same
using {g,s}etrlimit(2). The default limit is set to 64 descriptors.
If you want to set it above 256, you'll need to define FD_SETSIZE before
you include <sys/types.h> so that the FD_* macros works.

christos