Ventrix’s Code Folds

Java socket timeout

by ventrix on Jan.30, 2009, under android, j2ee, j2me, j2se, java

private String socketIP="192.168.1.1";
private int socketPort=2424;
private int timeout=5000; //5 seconds

Socket socket1 = new Socket();
socket1.connect(new InetSocketAddress(this.socketIP, this.socketPort), timeout);
//or else
Socket socket1 = new Socket();
socket1.connect(new InetSocketAddress(this.socketIP, this.socketPort));
socket1.setSoTimeout(timeout);

http://java.sun.com/j2se/1.4.2/docs/api/java/net/Socket.html

:
No comments for this entry yet...

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...