HTTP Protocol question

A

Aaron

I'm trying to learn how the HTTP protocol works. When aserver has many
clients accessing it at the same time. Say 200 people. How does it maintain
connection with 200 different concurrent client using only port 80? From
what I've read and if I understand this correctly, a TCP/UDP port a maintain
connection with one client at a time. Can someone explain it to me? I
believe FTP works the same way right?


Thanks in advance
Aaron
 
S

Scott Allen

Hi Aaron,

Here are some of the basics:

You can only open a single *passive* connection on a port. A passive
connection is a 'connection' that waits and listens for incoming
active connections. Once the web server starts listening on port 80 -
then no one else will be allowed to listen for incoming connections on
port 80 - this is why each server program listens on a different port.

You can have multiple *active* connections on a single port, as long
as each connection is unique, as determined by these 4 pieces of
information:

1) Host IP address
2) Host port
3) Client IP address
4) Client port

So for instance, if I run "netstat" from the command line I see my
computer has 2 concurrent connections open to a web server on my
network, but these connections originate from different local ports
(that IE picked at random):

Proto Local Address Foreign Address
TCP mycomputer:4239 10.10.10.10:http
TCP mycomputer:3927 10.10.10.10:http


(Also note Netstat replaces IP and PORT numbers with names when it
can).


As long as each connection is unique, there is never any confusion as
to where to send a packet. You can imagine 200 concurrent users
working because those 200 will all have different ClientIP:port
address portions - and because each connection is *uniquely
identifiable* - the web server will always know where to send the
response.

Make sense?
 
A

Andrew D. Newbould

Aaron said:
I'm trying to learn how the HTTP protocol works. When aserver has many
clients accessing it at the same time. Say 200 people. How does it maintain
connection with 200 different concurrent client using only port 80? From
what I've read and if I understand this correctly, a TCP/UDP port a maintain
connection with one client at a time. Can someone explain it to me? I
believe FTP works the same way right?


Thanks in advance
Aaron

In addition to Scot's excellent explanation ...

A web server normal deals with many clients by maintaining a Thread
Pool. The server determines whether it should Accept the incoming
connection and then passes the request, along with the client socket
details, to the thread pool. The thread pool then deals with the request
while the main Thread goes back to waiting for the next request.

This approach enables the web server to handle potentially thousands of
requests (seamingly simultaneously).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top