How do linux file descriptor limits work?

前端 未结 3 871
攒了一身酷
攒了一身酷 2020-12-23 18:08

I was told that my server refused to accept client network connections at a specific port could be due to the lack of file descriptors. I looked up what this is all about an

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 18:54

    It does not look like you are hitting the system file desriptor limit. See this answer.

    Perhaps your server process uses select and is thus limited to 1024 descriptors? If you switch to another mechanism, e.g. poll you will not be limited to 1024 descriptors anymore.

    select() works with fd_sets

    This is from the POSIX documentation of select.h:

    The following shall be defined as a macro:

    FD_SETSIZE

    Maximum number of file descriptors in an fd_set structure.
    

    Try to find or output FD_SETSIZE on your system.

    If you find FD_SETSIZE is too low for you, I would rather try to move away from select than trying to increase FD_SETSIZE which is typically harder.

提交回复
热议问题