0

For example, my server is listening on port 1234 and in same PC(host) 2 clients bind two sockets on ports(2000, 3000). Next, 2 clients connect to my server and my server will make client sockets for each clients.. When 2 sockets are accepted on server, 2 client sockets are created. I want to know when 2 sockets are created on server, does these sockets occupy two ports?

When I saw packet in WireShark, packets to server showed me same port(server's listening port).

Can I say that only listening socket occupies the port because of internal multiplexing? *If I am wrong, how do I check whether new client sockets occupy port? (netstat command didn't show me new ports)

user207421
  • 305,947
  • 44
  • 307
  • 483
DoyoHntr
  • 87
  • 5
  • 1
    Anyway see https://stackoverflow.com/questions/152457/what-is-the-difference-between-a-port-and-a-socket and https://stackoverflow.com/questions/25356976/confused-between-ports-and-sockets – CodeCaster May 30 '23 at 07:16
  • 1
    " I want to know when 2 sockets are created on server, does these sockets occupy two ports?": No. They occupy the same port as the listening socket. See RC 793. – user207421 May 30 '23 at 10:08
  • The clients created 2 socket objects, bound locally on `127.0.0.1:2000` and `127.0.0.1:3000`, and connected remotely to `127.0.0.1:1234`. The server created 3 socket objects, one bound locally on `127.0.0.1:1234` for listening, and 2 bound locally on `127.0.0.1:1234` and connected to the client ports. So, you have 5 socket objects total in memory, but only 3 ports are in use, and 2 connections are active between them. – Remy Lebeau May 30 '23 at 19:47

0 Answers0