Creating timed socket connections

Top  Previous  Next

To create a timed socket connection you may use the TimedSocket#getSocket method passing in a hostname, port and timeout as arguments.  A java.io.IOException will be thrown if a socket connection cannot be obtained within the defined timeout.

 

Example

 

String hostname = "www.myserver.com";

int port = 80;

int timeout = 5000; // 5 seconds

 

try

{

 Socket con = TimedSocket.getSocket(hostname,port,timeout);

}

catch(Exception ioe)

{

// handle exception

}





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC