I am newbie and started to learn java and servlets.
I have below query, I am running webserver in port 80.
Client A connects to the webserver and requesting some file.
Client B connects to the webserver at the same time and requesting for some other / same file.
How the webserver exactly knows how to serve the intended client? Meaning not resulted in serving wrong files to wrong client. This is for HTTP case.
How about normal TCP..instead of running webserver...writing socket pgm...like I am running some standalone java pgm in special port say 905.
Client A directly connects to this port thru TCP and send some raw string for processing.
Client B also connects to this port. How will work in this case?
In both cases it works the same, because HTTP is implemented on top of TCP/IP. The client sends a request, in the form of TCP packets. These packets contain the ip-address of the client, plus the port number. Together they form a socket. When two requests come in from different hosts, the server will simply return data to the same socket the request came from.
Yeah, it's kind of a wonderful thing how this whole internet works . Ultimately, at the physical level, a given computer can only talk to the network it's physically connected to. How does it manage to communicate to a server located across the world? To understand this well, you need to understand the OSI model of networkng. I can't even begin to do justice on the subject in a post. I spent 1 semester taking an intro course on networkng in my bachelor's course, an 3 years forgetting it
If you really want to understand how networkng works, I'm afraid you will either have to go to school, or pick a textbook
Micheal John John
posted 6 years ago
Thanks a lot Stephen and Jayesh. I started to explore more on this...