Actually I am learning Computer Networks and while at it, I am confused in how a web server maintains multiple connections?
Simply to state, I learned trough some googling is that sockets handles a each client request.
So lets say there is a web server and lets say 2 clients with IPs
Client A: 220.127.116.11 Client B: 10.10.10.10
They both try to connect to the server at port 80.
Now, from googling what I got is, the server listens at port 80 for incoming requests. Then lets say a client A tries to connect to the server (make TCP/IP connection). During which a socket is created between these two. Then it is executed as separate thread for its further communication making the server to again listen for other client requests at that particular port. And Client B connects the same way.
Now my first question is:
1. How does server communicate with these two clients simultaneously after the connection has been established?
Now practically not only 2 clients but thousands and millions user may connect to a server.
Then my next question is:
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?
Lastly, my 3rd question is:
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.
These are my basics questions that I'm not getting. Please correct me if I'm getting it all wrong. You can suggest me some books/pdfs to read if the answers are detailed or not partiularly focused on specific part. Thanks