To establish a server, you need to create a server socket and attach it to a port, which is where server listens for the connections. The port numbers are ranged from 0 to 65536, but port numbers 0 to 1024 are reserved for privileged services.The syntax to create a server socket is:
ServerSocket objectname = new ServerSocket(port);