Using ServerSocket class

This class is used by servers to listen for connection requests from clients. When you create a ServerSocket, it listens for connections on the specified port It is optional to specify a size of queue to queue up connections. getInetAddress( ) method returns the address of the connecting client.
accept( ) method accepts the requested connection and returns a Socket for future communications between client and server. A common model for network communications is for multiple clients to send requests to a single server program like Web server. To accomplish this task I'd recommend to arrange threads for each client request and form groups of threads for different type of services. /** * startServerSocket method is the simplest server socket example. * We register server socket on a specified port with a specified size of * connection queue. * * We define DataInputStream and PrintStream to connect later * to TCP/IP socket Input and output streams. * * ... Continuation on the next page ... Back To Java Networking