What is a socket?

Asked 2 years ago
Viewed 202 times

1 Answer


0

  • A server, in most cases, runs on a single computer and has a socket assigned to a certain port number. The server simply waits for a client to request a connection by listening to the socket.
  • From the client's perspective: The client is aware of the server's hostname as well as the port number on which it is listening. The client tries to connect with the server on the server's machine and port in order to make a connection request.
  • The client must also identify itself to the server by binding to a local port number that will be used throughout the connection. The system normally assigns this to you.
  • The server accepts the connection if all goes fine. The server receives a new socket tied to the same local port and its remote endpoint is configured to the client's address and port upon acceptance.
  • It requires a second socket so that it can continue to listen for connection requests on the old socket while also attending to the demands of the connected client.


Read More:

answered 2 years ago by Hitesh Vohra

Your Answer