To implement TCP/IP connections, the java.net package provides two classes, ServerSocket and Socket. A ServerSocket represents a listening socket that waits for connection requests from clients. S ServerSocket does not itself participate in connections it just listens for connections request and creates Sockets to handle the actual connection.

 A Socket represents one endpoint of an actual network connection.  A socket can be a client socket that sends a connection request to a server.  

The difference between handling Socket and ServerSocket is:

  1. ServerSocket is implemented on the server-side so that it can listen to the client’s requests and respond to them. While a socket is implemented at the client-side to send requests to the port of the machine where ServerSocket is listening.
  2. The socket class is used for the client side whereas ServerSocket is used for the server side.

Author

Currently, working as a Digital Marketing Officer was working as an IT Department Chief for a Financial Institution, and I am a part-time freelancer.

Leave a Reply