
90 }
91 catch (NumberFormatException nfe)
92 {
93 // non-numeric port value?
94 System.err.println(“NumberFormatException: “
95 + nfe.getMessage());
96 }
97 catch(IOException ioe)
98 {
99 // connection failed?
100 System.err.println(“IOException: “
101 + ioe.getMessage());
102 }
103 }
104 }
105
Compilation
C:\> j2sdk1.4.1_02\bin\javac.exe TCPServer1.java
C:\> dir
.
.
TCPServer1.class
.
.
Example Execution
C:\> j2sdk1.4.1_02\bin\java.exe TCPServer1
usage: java TCPServer1 <local_port>
Example: java TCPServer1 80
C:\> j2sdk1.4.1_02\bin\java.exe TCPServer1 80
*** listening on port 80
.
.
In Example 5.5, a TCP server socket is created, bound to the port supplied on the
command ...