How to set timeout on client socket connection?

后端 未结 3 1432
逝去的感伤
逝去的感伤 2020-12-29 03:15

I am trying to set the timeout of a connection on the client socket in java. I have set a default connect timeout to 2000, i.e:

this.socket.connect(this.soc         


        
3条回答
  •  死守一世寂寞
    2020-12-29 03:39

    You can even try for :

    Socket client=new Socket();   
    client.connect(new InetSocketAddress(hostip,port_num),connection_time_out); 
    

提交回复
热议问题