It occurs to me that I don't know how to formally define "port" in any context in which I know the word.
No I know but how do the integers map? Is it a hashmap implementation, what do they do under the hood when you specify e.g. port 8888
-
-
Hmm. Not sure what you mean exactly then, my apologies. It's not exactly mapping, you just tell your program what port to listen on. If you tell it to listen on 80 and point a web browser to localhost, your web browser will then be talking with your program.
-
Yes I know that but what does the 80 *do* that 79 *doesn’t*
-
Absolutely nothing :) That's the beauty. Ever use a web browser to connect to your home router on port 8080? Functionally identical to Port 80, they just use 8080 so as not to conflict with anything listening on 80
-
Yes I know this but there has to be some logic that filters by those values. Where is it and how is it implemented. # I should just read the spec
-
Each protocol has their own spec. Wanna send an email without an email client? Use telnet to connect to Port 25 on your email SMTP server. Use the smtp spec to find out what to type to send an email (usually a HELO command).
-
You’re explaining me things I already know but you’re answering different questions. I know specs exist. How are they *implemented*
-
Ports are essentially post office boxes. When the kernel receives a packet, it sorts the packet to the correct buffer by port number. If a program has informed the kernel it wants to listen on that port, then the kernel also wakes that program up to let it read the packet
-
A metaphor is not a formal definition
- 1 more reply
New conversation -
-
-
I didn't know either, so I spent some time reading the Linux inet source and it really looks like they're using a hashmap to squish src and dst ip and port together and map to a socket descriptor, which I guess makes sense
-
So I believe the process is, incoming packet fields (all fixed width, known offset) are hashed, the hashtable of open socket ids produces an integer to identify the socket, and then a program asking for a new packet uses the same socket integer to identify which packets it wants
-
that all happens in the OS itself, all an app does is make a system call to ask for a socket ID and then use the same socket ID for system calls to check for new incoming packets, so this is all effectively invisible most of the time.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.