"Note that ServerSocket is not used for communication between the server and the client; it is only used to wait for and establish the connection to the client. Typically, a single ServerSocket object is used over and over again to establish connections to any number of clients." [Flanagan97b, p192] This is demonstrated in the next example.
The choice of port number 8189 was arbitrary. A number of that size is guaranteed not to clash with any standard servers.
The previous example demonstrated how to set-up an input stream (or read) abstraction. This example adds to that an output stream (or write) abstraction.
This simple server:
It is not clear how many "streams" need to be closed. Horstmann closes only the socket object [p141], whereas Flanagan closes: the input object, the output object, and the socket object [p193].