1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| package fabrescan;
import java.net.*;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class FabriScan {
public static void main(String[] args)
{
//PScanner ps=new PScanner();
InetAddress ia=null;
String host="192.168.2.105";
try {
if(host!=null)
{
ia = InetAddress.getByName(host);
// for(;;)//boucle infinie
PScanner.scan(ia);
}
}
catch (UnknownHostException e)
{
System.err.println(e );
}
System.out.println("Bye from NFS");
}
public static class PScanner {
public int i;
public static void scan(final InetAddress remote)
{
for (int i = 0; i < 80; i++) {
int port1=i;
String hostname = remote.getHostName();
try {
Socket s1 = new Socket(remote,port1);
System.out.println("le port numéro " + port1+ " de " + hostname + "\n"+"est connecté");
s1.close();
}
catch (IOException ex)
{
System.out.println("le port numéro " + port1+ " de " + hostname+ " "+"n'est pas connecté");
}
}
}
}
} |
Partager