[comp.windows.x] MAX_CLIENTS limit

cmfb@cray.com (Chris Bone) (03/09/91)

Can anyone tell me where the maximum number of clients allowed is defined? I
currently have 18 (on a Sun 3/50 - os4.1 12Mb X11R4 twm) and on trying to open
number 19 this happens:
britain217%xclock &
[2]     253
britain218%Xlib:  connection to "britain:0.0" refused by server
Xlib:  Maximum number of clients reached
Error: Can't Open display

I have looked through Xlib.h - nothing obvious. grep'ing through the source
didn't help either! I checked all the man pages and installation notes that
seemed appropriate. Hmm.
Any advice much appreceated!
Regards,
           __
          /  ) /
         /    /_  __  o _
        (__/ / /_/ (_/_/_)_

klee@wsl.dec.com (Ken Lee) (03/09/91)

In article <092038.4078@timbuk.cray.com>, cmfb@cray.com (Chris Bone) writes:
|> Can anyone tell me where the maximum number of clients allowed is defined? 

This is set by the server.  Some operating systems, for example, allow
only 32 open files per process or restrict select() to 32 descriptors.
Servers on these systems will stop accepting clients when these limits
are reached.

There are similar limits in Xlib for the maximum number of displays
that can be opened, though this is rarely a problem.

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

mouse@lightning.mcrcim.mcgill.EDU (der Mouse) (03/09/91)

> Can anyone tell me where the maximum number of clients allowed is
> defined?

As someone else already noted, it's the server that's doing this (as
would have to be the case); in the case of the MIT server, it does a
getdtablesize() when it starts up and starts refusing new clients when
it's within one or two of running out.

> I currently have 18 (on a Sun 3/50 - os4.1 12Mb X11R4 twm) and on
> trying to open number 19 this happens:

The *server* is running under 4.1?  Something weird is wrong then; 4.1
by default has the descriptor limit set to 64, I believe.  You should
be able to connect about 55 clients before it starts losing.  Your
symptom looks more like what I'd expect from a server running under
release 3.5.

As to what can be done about it, besides switching to an OS that allows
more file descriptors per process....

I hacked on the server so that it can fork a multiplexor subprocess to
alleviate this problem.  This raises the effective maximum to about 30.
I could make it do multiple multiplexors, but have never felt any need;
I've never run out of clients since.

I do not have these changes in the form of distributable diffs.  If you
want to take your chances with the raw code, they should be available
for ftp from 132.206.1.1, in X/myX/X11R4/server/os/4.2bsd/ (you want to
look at the MUX_CONN compile-time option.)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu