Tag: socket timeout
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