[Tutor] Number of socketdescriptors > 250 and open() failed with to many open files

Ewald Ertl ewald.ertl at hartter.com
Thu Mar 31 17:07:14 CEST 2005


Hi!

In a class derived from thread I open a socket-Connection to a remote 
Server. 
Here I start about 500 Thread's on a solaris-System. Sofar there is no 
problem, when the filedescriptorlimit is set high enough with ulimit -n. 

My Problem is, when a function in the class tries to open a regular file 
in the filesystem. Because of some limitations of the FILE-Structure ( in C ) 
it's not possible to open more files than  255. I think, that this is the problem 
here in python, when open() delivers "too many open files". 

In my C-Daemon I duplicated the socket-descriptors with fcntl to start after a 
offset with e.g. fcntl( socket, F_DUP, 100 ). 
And after this I use the new descriptor and close the old one. So there are everytime 
some descriptors below 255 ready for opening regular files. 

I tried the same thing in python. socket.fileno() delivers the descriptor of the
opened socket.  
The fcntl-Call in the module fcntl does also succeed. But after this I need 
a socket-Object for working on with the new filedescriptor. 
Constructing a new socket-Object with socket.fromfd() does not work, because 
this takes a new descriptor at the same low offset. 

Is there any possibility to get a socket-Object which uses the allready obtained 
filedescriptor from fcntl()? 


Thanks 

Ewald 



More information about the Tutor mailing list