Java Reference
In-Depth Information
report.append(
"There is a server on port "
+ i + ".\n");
socket.close();
}
catch (IOException ioEx)
{}// No server on this port
}
}
catch (UnknownHostException uhEx)
{
report.setText("Unknown host!");
}
}
}
When the above program was run for the default server (which is on the
author's local network), the output from the GUI was as shown in Fig. 2.8 .
Unfortunately, remote users' fi rewalls may block output from most of the ports
for this default server (or any other remote server), causing the program to wait
for each of these port accesses to time out. This is likely to take a very long time
indeed! The reader is strongly advised to use a local server for the testing of this
program (and to get clearance from your system administrator for port scanning,
to be on the safe side). Even when running the program with a suitable local
server, be patient when waiting for output, since this may take a minute or so,
depending upon your system.
Fig. 2.8 Example output
from the PortScanner
program
Search WWH ::




Custom Search