accept error: Too many open files

今天测试socket服务器同一时间处理多个客户端连接问题,第一次测试1000个的时候没问题,第二次测试1000个服务器accept的时候就报错了

accept error: Too many open files

看来打开的socket数目已经超过单进程最大文件描述符限制了

查看一下系统设置

$ulimit  -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 62597
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 62597
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
$

可以看到

open files                      (-n) 1024

也就是单个进程最多可以打开1024个文件描述符

转载于:https://www.cnblogs.com/tid-think/p/10750850.html

你可能感兴趣的:(accept error: Too many open files)