socket programming - why web server still using listen port 80 to communicate with client even after they accepted the connection?

前端 未结 5 664
渐次进展
渐次进展 2021-01-21 05:13

Usually a web server is listening to any incoming connection through port 80. So, my question is that shouldn\'t it be that in general concept of socket programming is that port

5条回答
  •  天涯浪人
    2021-01-21 05:42

    shouldn't it be that in general concept of socket programming is that port 80 is for listen for incoming connection. But then after the server accepted the connection, it will use another port e.g port 12345 to communicate with the client.

    No.

    But, when I look into the wireshark, the server is always using port 80 during the communication.

    Yes.

    I am confused here.

    Only because your 'general concept' isn't correct. An accepted socket uses the same local port as the listening socket.

    So what if https://www.facebook.com:443, it has hundreds of thousands of connection to the it at a second. Is it possible for a single port to handle such a large amount of traffic?

    A port is only a number. It isn't a physical thing. It isn't handling anything. TCP is identifying connections based on the tuple {source IP, source port, target IP, target port}. There's no problem as long as the entire tuple is unique.

提交回复
热议问题