import java.net.*;
import java.io.*;
class Socketinfo
{
public static void main(String[]args)
{
String host = "localhost";
try
{
Socket theSocket = new Socket(host, 80);
System.out.println("Connected to" +theSocket.getInetAddress()
+"on port" +theSocket.getPort() +"from port"
+ theSocket.getLocalPort()+"of"+theSocket.getLocalAddress());
}
catch (UnknownHostException e)
{
System.err.println("I can't find"+host);
}
catch (SocketException e)
{
System.err.println("Could not connect to"+host);
}
catch (IOException e)
{
System.err.println(e);
}
}
}
import java.io.*;
class Socketinfo
{
public static void main(String[]args)
{
String host = "localhost";
try
{
Socket theSocket = new Socket(host, 80);
System.out.println("Connected to" +theSocket.getInetAddress()
+"on port" +theSocket.getPort() +"from port"
+ theSocket.getLocalPort()+"of"+theSocket.getLocalAddress());
}
catch (UnknownHostException e)
{
System.err.println("I can't find"+host);
}
catch (SocketException e)
{
System.err.println("Could not connect to"+host);
}
catch (IOException e)
{
System.err.println(e);
}
}
}
selamat mencoba
0 komentar:
Posting Komentar