设置文件最大打开数

    struct rlimit r_limit;
    r_limit.rlim_cur = 4096;
    r_limit.rlim_max = 4096;
    if (setrlimit(RLIMIT_NOFILE, &r_limit) == -1) {
        printf("FAIL\n");
        return 1;
    }

当我弄了个服务器,写了段测试代码发现一连接到900多个时就连不上了,结果是需要设置最大连接数,而且还必须在测试客户端用上这段代码。。。

你可能感兴趣的:(文件)