简体   繁体   English

C ++服务器-超过1024个连接

[英]C++ Server - More than 1024 connections

I have a chat server in C++, running in linux and using the libev libraries. 我有一个C ++聊天服务器,在Linux上运行并使用libev库。 If I try to connect more than 1024 clients it will crash with a -1 file descriptor. 如果我尝试连接1024个以上的客户端,它将使用-1文件描述符崩溃。

I would like to allow more than 1024 concurrent connections to be made to the server. 我想允许与服务器建立1024个以上的并发连接。 With looking at the libev documents it looks like it can be configured to use select, poll and epoll although I'm not sure what the default is. 通过查看libev文档,似乎可以将其配置为使用select,poll和epoll,尽管我不确定默认值是什么。

Any tips or references on how to increase the limit of file descriptors using libev would be greatly appreciated! 任何有关如何使用libev增加文件描述符限制的提示或参考,将不胜感激!

You need to increase your allowed per-process file handles. 您需要增加允许的每进程文件句柄。 You can allow a user to use more filehandles with this: 您可以通过以下方式允许用户使用更多文件句柄:

# Put this in /etc/security/limits.conf
someusername       soft    nofile  65535
someusername       hard    nofile  65535

(where someusername is the user that will run your program.) (其中someusername是将运行您的程序的用户。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM