Shivam Aggarwal
Shivam Aggarwal

Reputation: 774

Creating a socket VS creating a connection

I'm new to socket programming and would like to ask some basic questions-

  1. A socket is just one end point out of the millions of endpoints over the internet. True ?
  2. A socket(on client side) uniquely tells which application I'm running and on which machine out of the billions of simultaneously running applications on millions of devices on the internet. True ?
  3. Who makes socket, the programmer or are implicitly built by the underlying OS?
  4. What does it mean to create a socket ? Both on the server and client side.
  5. Based on above question on what creating socket means, does creating a socket means establishing connection between the client and server,
    IF YES, who establishes the connection, the OS ?
    IF NO, again then who establishes the connection, who connects those two sockets ?
  6. How does a single server with one particular socket handle multiple requests from clients simultaneously ?

Upvotes: 1

Views: 1360

Answers (1)

user207421
user207421

Reputation: 310884

  1. A socket is just one end point out of the millions of endpoints over the internet. True?

False. 'Endpoints over the Internet' is meaningless. A socket is an endpoint of a connection, which might have nothing to do with the Internet whatsoever. A socket can also be unconnected.

  1. A socket(on client side) uniquely tells which application I'm running and on which machine out of the billions of simultaneously running applications on millions of devices on the internet. True?

False. A socket is owned by a process, which in turn runs in a specific host. You're basically putting it back to front.

  1. Who makes socket, the programmer or are implicitly built by the underlying OS?

Neither. The application asks the operating system to create a socket.

  1. What does it mean to create a socket ? Both on the server and client side.

It means creating a socket. Unclear what you're asking here, or what kind of an answer you're expecting.

  1. Based on above question on what creating socket means, does creating a socket means establishing connection between the client and server,

No.

IF YES, who establishes the connection, the OS ?

See above.

IF NO, again then who establishes the connection, who connects those two sockets ?

The application asks the operating system to connect the socket to a target IP address and port.

  1. How does a single server with one particular socket handle multiple requests from clients simultaneously ?

The operating system creates a new socket for every accepted connection.

Upvotes: 2

Related Questions