A server derived class application

The previous example set-up the necessary server infrastructure. All that remains to create a real server application is to inherit from ServerBaseClass and override the run(Socket) method.

The Socket parameter is the "pipeline" to the client that has just established a connection. Input (read) and output (write) streams are retrieved from the Socket object. The "protocol" for exchanging data between the server and the client is:

main() gets everything started by creating an instance of the server derived class, and then calling the startServer() method defined in the server base class.

The client application requests a connection on a pre-arranged port number. It then proceeds to play the role reserved for it in the protocol described above.