Re: Setting TCP parameters for Socket?

On 27/10/11 17:48, markspace wrote:
Socket sock = new Socket( hostname, port );
sock.setSoTimeout( 6000 ); // too late!

There's no way that I can see to change the time out of the initial connection, which occurs in the first line above, in the constructor. You can set the time out for subsequent reads, but not the first connect.

Is anything stopping you from created an unconnected Socket, then calling connect() on it, with the timeout specified as an argument?

You could also try setSoTimeout() between the constructor and connect(), but it appears to be for reads, not necessarily connects. Of course, that might be the only way for other socket options.

ss at comp dot lancs dot ac dot uk


Relevant Pages