setSoTimeout on a client socket doesn't affect the socket

前端 未结 2 1312
天涯浪人
天涯浪人 2021-01-23 19:52

I have a Java application with three threads that open, each, a socket and connect to a server on different ports. I set so_timeout on each of these sockets after the connection

2条回答
  •  臣服心动
    2021-01-23 20:22

    The documentation says:

    The option must be enabled prior to entering the blocking operation to have effect.

    maybe you should set it before the connection to the server is established, at least before calling read() on the socket.
    But hard to say without the code...

提交回复
热议问题