How can I set Socket write timout in java?

后端 未结 1 701
萌比男神i
萌比男神i 2020-12-20 03:24

I have a problem with handling socket in java. I am running a TCP server with multiple client connections.

For performance reason, I used a simple thread pool to h

1条回答
  •  情深已故
    2020-12-20 03:42

    How can I set Socket write timout in java?

    You can't. There is no socket write timeout in Java. Unless you make the hyperjump to NIO, non-blocking mode, Selectors, etc.

    I got tons of exception flooding SocketException: Broken pipe from out.write(buffer);

    You should only get one. You should close the socket when you get this exception.

    0 讨论(0)
提交回复
热议问题