java.net.SocketTimeoutException vs java.net.ConnectException

前端 未结 4 886
暗喜
暗喜 2021-01-04 20:07

When connecting to a server with a Java client socket I had this two different connection timeout exceptions.

Caused by: java.net.SocketTimeoutException: con         


        
4条回答
  •  醉话见心
    2021-01-04 20:52

    Caused by: java.net.SocketTimeoutException: connect timed out
    

    When you are not able to connect due to unavailability of the peer. Your second query, what about read? Than you will get

     Caused by: java.net.SocketTimeoutException: Read timed out
    

    Third possibility connection refused if peer is active but refused the connection.

提交回复
热议问题