• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How webserver knows which client to reply

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

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?
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Micheal, welcome to CodeRanch!

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.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Stephen and Jayesh. I started to explore more on this...
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic