Selasa, 31 Mei 2011

Script Java Menampilkan Port Yang Terkoneksi

Langsung copas kode di bawah ini...:-)

import java.net.*;
import java.io.*;

class Soal3
{
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



Artikel Terkait



0 komentar:

Posting Komentar

Template by : kendhin