public static void scan ( InetAddress remote, int port) {
int winport1 = 135;
int winport2= 445;
boolean check = false;
String hostname = remote.getHostName();
try {
Socket s = new Socket(remote,port);
System.out.println("Gegenstelle hat Port Nummer: " + port+ ". IP Adresse: " + hostname);
s.close();
try {
doc.insertString(doc.getLength(), "Die Gegenstelle hat den Gesuchten Port: "+port+" IP Adresse: "+hostname +"\n", gewählt);
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
check = true;
}
catch (IOException ex) {
System.out.println("Gegenstellen hat nicht: " + port+ ". IP Adresse: " + hostname);
try {
Socket s = new Socket(remote,winport1);
System.out.println("Gegenstelle hat Port Nummer: " + winport1+ ". IP Adresse: " + hostname);
s.close();
try {
doc.insertString(doc.getLength(), "Die Gegenstelle hat den Gesuchten Port: "+port+" IP Adresse: "+hostname+"\n", windows);
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
check = true;
}
catch (IOException ex1) {
System.out.println("Gegenstellen hat nicht: " + winport1+ ". IP Adresse: " + hostname);
try {
Socket s = new Socket(remote,winport2);
System.out.println("Gegenstelle hat Port Nummer: " + winport2+ ". IP Adresse: " + hostname);
s.close();
try {
doc.insertString(doc.getLength(), "Die Gegenstelle hat den Gesuchten Port: "+port+" IP Adresse: "+hostname+"\n", windows);
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
check = true;
}
catch (IOException ex2) {
System.out.println("Gegenstellen hat nicht: " + winport2+ ". IP Adresse: " + hostname);
int port2 = 0;
while (check == false && port2 <= 65535){
try {
Socket s = new Socket(remote,port2);
System.out.println("Gegenstelle hat Port Nummer: " + port2 + ".IP Adresse: " + hostname);
try {
doc.insertString(doc.getLength(), "Die Gegenstelle hat den Gesuchten Port: "+port+" IP Adresse: "+hostname+"\n", null);
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
s.close();
check = true;
}
catch (IOException ex3) {
System.out.println("Gegenstellen hat nicht: " + port2+ ". IP Adresse: " + hostname);
check = false;
}
port2 = port2 + 1;
}
}
}
}
}