书上说是5个,那要是想同时支持50个客户的并发请求怎么办? 请教高手指点,谢谢

解决方案 »

  1.   

    默认是一个端口只能一个连接一个的,你想一个端口接收很多的连接需要使用select 模型或者i/o模型.
      

  2.   

    to ouyh12345 ,对于超过64个连接的,只能用完成端口实现了吗
      

  3.   

    楼主所所说的5个,应该是指listen队列的最大值(默认是5)。
    对于同时支持多少连接与服务器有关,windows平台一般5000,而unix平台能达10000以上listen(sServer, 5);
    while (1)
    {
      socket sClient = accept(sServer, NULL, NULL);
    }
      

  4.   

    to robertxiao:
    按您的说法,针对一个端口的listen,最大值是5,或者更大一些比如是10,那么如果同时来了20个客户请求,怎么才能让他们都得到响应而不是被拒绝呢? 
      

  5.   

    MSDN:
    Maximum length of the queue of pending connections. If set to SOMAXCONN, the underlying service provider responsible for socket s will set the backlog to a maximum reasonable value. There is no standard provision to obtain the actual backlog value. 我也觉得给client retry机会 会好一些