What Is Socket and Serversocket in Java

Socket class represents a socket, and the java. net. ServerSocket class provides a mechanism for the server program to listen for clients and establish connections with them. … The constructor of the Socket class attempts to connect the client to the specified server and the port number.

What is a ServerSocket in java?

ServerSocket is a java.net class that provides a system-independent implementation of the server side of a client/server socket connection. … The accept method waits until a client starts up and requests a connection on the host and port of this server.

What are sockets and ports?

Both Socket and Port are the terms used in Transport Layer. A port is a logical construct assigned to network processes so that they can be identified within the system. A socket is a combination of port and IP address. … The same port number can be used in different computer running on same software.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest