Why a “java.net.SocketException: Broken pipe” will occur?

后端 未结 4 2049
梦谈多话
梦谈多话 2021-01-12 11:26

I wrote a simple socket programme, it works fine, but my friend use a port scanning tool, when it scan to the port I am using, it cash with \"java.net.SocketException: Broke

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-12 12:23

    The reason of your problem may be here:

    JavaDoc:

    The maximum queue length for incoming connection indications (a request to connect) is set to 50. If a connection indication arrives when the queue is full, the connection is refused.

    And you should increase "backlog" parameter of your ServerSocket, for example

    int backlogSize = 50 ;
    providerSocket = new ServerSocket(portNum, backlogSize);
    

提交回复
热议问题