TCP/IP Server Socket in Advanced Java
TCP/IP Server Socket:
Java has a different socket class that must be used for creating server applications. The TCP/IP Server Socket class is used to create servers that listen for either local or remote client programs to connect to them on published ports. ServerSockets are quite different from normal Sockets.
When you create a ServerSocket, it will register itself with the system as having an interest in client connections. The queue length tells the system how many client connections it can leave pending before it should simply refuse connections. The default is 50.
Constructor to Create TCP/IP Server Socket:
ServerSocket(int port) throws IOException: Creates server socket on the specified port with a queue length of 50.
ServerSocket(int port, int maxQueue) throws IOException: Creates a server socket on the specified port with a maximum queue length of the max queue.
ServerSocket(int port, int maxQueue, InetAddress local address) throws IOException: Creates a server socket on the specified port with a maximum queue length of the max queue. On a multihomed host, the local address specifies the IP address to which this socket binds.