Reputation: 1689
I need to set time for max connection time in a socket client. But if I do like the following code, does not work, because line one open a connection and is a blocking function and never run line two.
How can I setSoTimeout before open connection?
Socket s = new Socket(server.host, server.port);
s.setSoTimeout(server.time);
Upvotes: 1
Views: 582
Reputation: 1851
Socket socket=new Socket();
socket.connect(new InetSocketAddress(host,port),timeout);
Upvotes: 1