实际上,我正在学习计算机网络,同时,我对 Web 服务器如何维护多个连接感到困惑?
简单地说,我通过谷歌搜索了解到套接字处理每个客户端请求。
所以假设有一个网络服务器,假设有 2 个具有 IP 的客户端
Client A: 5.5.5.5
Client B: 10.10.10.10
他们都尝试在端口 80上连接到服务器。
现在,通过谷歌搜索我得到的是,服务器在端口 80侦听传入请求。然后假设客户端 A尝试连接到服务器(进行 TCP/IP 连接)。在这期间会在这两者之间创建一个套接字。然后它作为单独的线程执行以进行进一步的通信,使服务器再次侦听该特定端口上的其他客户端请求。和客户端 B以相同的方式连接。
现在我的第一个问题是:
1. How does server communicate with these two clients simultaneously
after the connection has been established?
现在实际上不仅有 2 个客户端,而且有成千上万的用户可以连接到服务器。
那么我的下一个问题是:
2. Now, how do those thousands of clients get connected to a single server?
If we assume every client is connected to the server through wire, it is not
practically possible to maintain that many sockets on a hardware for
connection. How those thousands connections are made and handled?
最后,我的第三个问题是:
3. Above I said (actually heard) how **client A** connected to the the server
and similarly the client B.
But I didn't get the part stating "after a TCP/IP connection is made they
continue separately in a separate socket and making server to listen for
other client requests." What does that mean? If one client is communicating
to the server, how come other can communicate at the same time to same server.
Isn't it like while a student is asking question to a teacher, other can't
ask at the same time since that particular student is busy or occupying the
teacher at the moment so others should wait, which we compare than client B
should wait when client A is communicating.
这些是我没有得到的基本问题。如果我都弄错了,请纠正我。如果答案很详细或没有特别关注特定部分,您可以建议我阅读一些书籍/pdf。谢谢