Last active
January 1, 2016 15:39
-
-
Save mr-fool/8165363 to your computer and use it in GitHub Desktop.
Simple networking attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.Socket; | |
/** | |
* @author mr-fool | |
* @param a simple network tool*/ | |
public class SocketProxy extends Thread { | |
public static void main (String[] args) { | |
String address = args[0]; | |
int port = Integer.parseInt(args[1]); | |
/** | |
* @param trying to connect | |
* @param set timeout to 9000 */ | |
try { | |
System.out.println ("Attempting to connect " + address + ":" + port); | |
Socket connection = new Socket(address,port); | |
System.out.println("Connection status: " + connection.isConnected() ); | |
connection.setSoTimeout(9000); | |
System.out.println ("Connected to " + connection. getRemoteSocketAddress()); | |
System.out.println ("Time out is setted to 9000 milisecond"); | |
} | |
catch (Exception e){ | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment