[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

why doesn't client side also use port 80 for http? why

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 64
Thread images: 2

File: 1480159868292.jpg (71KB, 550x550px) Image search: [Google]
1480159868292.jpg
71KB, 550x550px
why doesn't client side also use port 80 for http?
why does the client side have to use ephemeral ports?
>>
pls respond
>>
pls respond pls
>>
>>57786318
Why should it? If it used only 80th port, you wouldn't be able to open two client connections at the same time
>>
80 is a privileged port, also your can only bind one tcp connection to one port at a time so...
>>
>>57786390
why 2 and not one?
>>
>>57786396
>>57786390
Then how does a server accept one million connections on port 80? Checkmate atheists!
>>
>>57786396
so then how does a server deal with many connections at once just on port 80?
>>
>>57786318
>why does the client side have to use ephemeral ports?
listening ports are for... listening. why would the client be listening?
>>
>>57786445
memes aside, i actually want an answer for this
>>57786455
to receive the requested information/website, i assume
>>
pls respond 3
>>
>>57786318
pls respond 4
>>
>Question implies that Marty's pizza was bigger
>Kid answers right
>Teach give you the finger and says you're wrong anyway

What the fuck kind of math are they teaching nowadays?
>>
>>57786528
ikr teachers a cunt
pls answer my questions
>>57786471
>>
>>57786528
Common Core. Welcome to hell.
>>
pls respond 5
>>
>>57786390
lmao bro
>>
>>57786318
Because non-ephemeral ports require (or at least used to) super user privileges.
>>
>>57786565
interesting answer thank you
>>
>>57786445
>>57786471
The server can connect multiple times on port 80 because the source port is different for each connection.

A connection is uniquely identified by (source ip, source port, destination ip, destination port).

If both alice and bob have fixed IPs, and bob's IP (80) is fixed, then the only way alice can open multiple connections to bob is by varying the source port.

Only based on that information can the connection tracker / TCP implementation associate each packet with the particular connection it belongs to.
>>
>>57786594
https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports

https://linux.die.net/man/5/services
>Port numbers below 1024 (so-called "low numbered" ports) can only be bound to by root (see bind(2), tcp(7), and udp(7)). This is so clients connecting to low numbered ports can trust that the service running on the port is the standard implementation, and not a rogue service run by a user of the machine. Well-known port numbers specified by the IANA are normally located in this root-only space.
>>
>>57786619
>The server can connect multiple times on port 80
misleading wording, should be “can be connected to”

>and bob's IP (80)
and bob's port*
>>
>>57786619
Note, connection tracking is needed for more than just TCP implementations, it's also important for firewalls, NAT, routing, load balancing and other fun stuff.

So being able to uniquely identify connections based on the source port is important.
>>
>>57786318
I've always wondered how that works. so clients actually open up a random port? how does it get past the router without forwarding?
>>
>>57786649
port forwarding is required only for incoming connections in PAT situations, which everyone here will call NAT. PAT is distinct from NAT in that there is a one to many mapping of public addresses to private addresses and operates at layer 4 rather than layer 3. And since the connection is outgoing, a port forwarding entry is not required. The router simply sees the outgoing connection and builds a temporary rule automatically.
>>
Wait if a client opens up a random port to communicate with the server, then does that mean that a client can only open up to 65536 simultaneous connections to any host?
>>
>>57786619
>>57786642
>>57786690

ah yes thank you i dont completely understand but it gives some insight and i will save these notes for later
>>
>>57786703
to any host? no. to any one host? yes.
>>
>>57786751
Are you sure?
If I open up 65536 connections to google.com and leave them all open, how will I open up another connection to 4chan.org if all 65536 ports have been taken already?
>>
>>57786318
Because it's a client. The well-known port is reserved for a service whose port should be, well, well-known. It is of no benefit to the server to know the client's port in advance because this information is received in the original SYN segment and the server thus knows what port to talk to.

Also, imagine browsing the web from a system which also also is running a web server of its own. You cannot have two identical sockets open at the same time. That's also why ephemeral ports are used for the client side - so as not to interfere with any services which might be running on the client.
>>
>>57786787
Because the destination IPs would be different. Any modern TCP/IP implementation will look at source and destination IPs and ports to determine which socket to send data to. It is how servers can accept multiple connections to a single port, although there is no reason why clients can do the same and re-use ports.
>>
>>57786828
>Any modern
any mature
>>
>>57786820
>...
this isnt the reason >>57786565 is

>Also, imagine browsing the web from a system which also also is running a web server of its own.
this would only be an issue if it was trying to connect to itself
>>
>>57786828
but the ports on the connection from client computer to their soho router, which uses a baseband connection will be maxed out
please explain
>>
>>57786649
NAT is stateful. The first packet in a TCP handshake is an outgoing connection attempt. So for example, say I want to visit 4chan.org on port 80

My kernel's TCP/IP implementation picks some random port (say 12345) and uses it for the source port. So the first thing my firewall sees is a connection attempt that looks something like this:

TCP SYN - source ip: 192.168.0.2, source port: 12345, destination ip: 104.16.65.203, destination port: 80

The NAT implementation then has to rewrite this packet, so it looks up its own IP and picks a random free port on its machine, say my public IP is 10.1.2.3 and the port I pick is 54321

The original packet then gets rewritten to:

TCP SYN - source ip: 10.1.2.3, source port: 54321, destination ip: 104.16.65.203, destination port: 80

in addition to sending out this modified packet, the router creates an entry in its connection tracking state table which says “port 54321 should be forwarded to 192.168.0.2:12345”.

When a reply comes back from the 4chan.org server, it will look like this:

TCP SYN+ACK - source ip: 104.16.65.203, source port: 80, destination ip: 10.1.2.3, destination port: 54321

The router looks up its state table and finds the 54321 entry, and therefore rewrites this packet back to

TCP SYN+ACK - source ip: 104.16.65.203, source port: 80, destination ip: 192.168.0.2, destination port: 12345

which gets sent back to the original host (me).
>>
>>57786828
Ah so ports can be binded to multiple times as long as the other details are different. interesting.
What would happen if a server binded to port 80 twice, one as 127.0.0.1 and the other as 192.168.0.2 (same machine).
They're two different addresses therefore they should bind, but what will happen?
And as an extension to that question, what would happen if the server binded to port 80 a third time as 192.168.0.3 (a different machine). how will packets get routed then?
>>
>>57786919
>They're two different addresses therefore they should bind, but what will happen?
One will listen on 127.0.0.1 only and the other will listen on 192.168.0.2 only

Not sure what you're asking
>>
>>57786318
imagine you have fight over a gloryhole with your tiny white 3 inch dick and jamals 18 incher
>>
>>57786901
>but the ports on the connection from client computer to their soho router, which uses a baseband connection will be maxed out
what?

>>57786919
>What would happen if a server binded to port 80 twice, one as 127.0.0.1 and the other as 192.168.0.2 (same machine).
you would have two connections? pic related, me ssh'ing in to myself twice
>>
>>57787024
What I'm asking is that both address point to the same machine, so,
Say httpd A is listening on 127.0.0.1 and httpd B is listening on 192.168.0.2, both on port 80, and then from another machine I did
curl http://192.168.0.2
it would go to httpd B.
And then on the server machine I did
curl http://127.0.0.1
, it would go to httpd A.
Is that correct?
>>
>>57786919
>And as an extension to that question, what would happen if the server binded to port 80 a third time as 192.168.0.3 (a different machine). how will packets get routed then?
also this wont happen, you can only have a single connection for the same source and destination ip and port pair.
>>
>>57787078
Pretty much. The destination IP matters for the sake of figuring out which listening port to associate it with.

Note that this has very little to do with what >>57786828 said, which is about the client making connections to multiple web servers, not the web server accepting connections from multiple clients.
>>
>>57786318
Because Marty pizza is 73% bigger.
>>
>>57786690
Ok but when the server responds and sends back a packet, how does the router know where to forward the packet to? does it persist the temporary rule during the whole connection?
>>
>>57787084
The server could easily have multiple IP addresses, though. But that sort of conflicts the “(a different machine)” part of the question.

I think >>57786919 is probably just somewhat confused.
>>
>>57787130
See >>57786917

And yes, the connection tracking entry will persist until the connection is closed or expires (times out).
>>
>>57787130
>how does the router know where to forward the packet to?
from its PAT tables

>does it persist the temporary rule during the whole connection?
yes, although most enterprise class devices have a configurable timeout

>>57787132
127.0.0.1 and 10.2.2.0 are multiple ip addresses
>>
>>57787132
>>57786919
nevermind i was retarded and didnt notice the different machine part. its early, forgive me
>>
>>57787161
>127.0.0.1 and 10.2.2.0 are multiple ip addresses
Yes, but I mean a single physical machine could be listening on multiple public IPs, and have a different program running on port 80 of each IP. The user wouldn't even be able to tell it's on the same physical machine.
>>
>>57786318
Holy shit is this what gets taught to Americans? No wonder millennials worship drugs and the BBC.
>>
>>57787231
> it took 48 replies for some autist to get mad from that shitty bait

wow /g/ is actually getting better lately
>>
>>57787231
I'm assuming it is Common Core which Trump will hopefully roll back considering it was one of his campaign promises, but considering his pick for Secretary of the Dpt of Education it now seems unlikely as she was a supporter of it.

>>57787230
the packets would get routed as they always do, they'll go to the socket which corresponds to the client and server ip and port pair of both endpoints.
>>
>>57787127
lol nope.
its 45%
>>
>>57787259
How is that image "bait"? Your American educational system is so fucked. No wonder your top universities take in more and more foreign born students every year.
>>
>>57787281
if a source and destination use the same port to connect to each other would it work?
like
source port: 1234
destination port: 1234
>>
>>57787340
>Your American educational system is so fucked. No wonder your top universities take in more and more foreign born students every year.
They take more because foreign born students are retarded enough to want to spend a $280k over 4 years to go to school which believes in safe spaces. regardless of what they call themselves, they're all doing it for profit.

https://www.washingtonpost.com/opinions/how-to-create-inclusive-campus-communities-first-create-safe-places/2016/01/15/069f3a66-bb94-11e5-829c-26ffb874a18d_story.html

>>57787352
if the IPs are different, it will work. if the IPs are the same the connection wont be established.
>>
>>57787371
I am talking about Harvard, MIT, etc.
>>
>>57787371
ok thx. http listens on port 80.
does a http service speak on port 80 as well?
>>
>>57787422
>I am talking about Harvard, MIT, etc.
Northwestern is one of the US's top schools

>>57787458
that makes no sense
>>
>>57787466
>that makes no sense
so i take it as a no?
on what port would a http server speak on,
like send the website information in response to a request from a client?
an ephemeral port?
maybe im asking the question badly idk
>>
>>57787466
maybe i should be asking
does a device listen and speak on the same port at the same time? or does it use one port to listen and another port to speak?
>>
>>57787523
>does a device listen and speak on the same port at the same time?
It can

>or does it use one port to listen and another port to speak?
there is no reason why it couldn't but generally no this doesnt happen
>>
>>57786318
I would like to laugh that teacher in the face.
>>
Can you guys stop posting these pictures that OP does? I AM SO PISSED OFF! how can a teacher fail like that?
Thread posts: 64
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.