14 ms·
What does it mean to listen on a port?
- schwurb 5y agoGreat article! Love the story approach.
- xyzzy21 5y agoI guess things are different since the 1980s when writing C code to implement "listening" on a port using the listen() call made this obvious.
- piyh 5y agoI love articles like this where it goes deeper into a fundamental idea that I've only interacted with on a "do what I need done" level.
- theamk 5y agoFundamental? I see it the other way -- this is an illustration of how neat, fundamental concept ("When you bind to a port, it puts a pointer to your socket in that table.") is actually full of random hacks and ad-hoc changes. The linux kernel is full of random logic like this, and this article could be continued (there are at least network namespaces and sys.net options to consider). Don't get me wrong -- all of this functionality is useful in some context, and it is there for a reason. We cannot radically simplify the kernel without making it less useful. But it is still somewhat sad there is so much essential complexity even in simple things like "listen" call.
- oblio 5y agoWe can't really blame Linux for this, this is a networking protocols problem. It's their stack of hacks.
- ratorx 5y agoWell only sort of. As far as I understand, nothing about TCP means that ports can be reused, or that 0.0.0.0 has special meaning, or that processes can’t listen on the same port, or IPv4 to IPv6 delivery etc. These are all operating system design choices, some of which stem from the sockets API. I’m pretty sure you could design a spec-compliant alternative which didn’t do any of these things, if you really wanted to.
- wyager 5y agoTCP and UDP don't really dictate any of this behavior. Most of these hacks are the result of design choices in Linux and the socket API - abstractions on top of TCP/UDP that aren't the only option. In my experience, the network layer is often way better-designed, more reliable, more interoperable, and less hacky than most OS abstractions built on top of it.
- xg15 5y agoThis article has taught me the concept of "discovery fiction" and, I'm sorry to say so, but I already hate it. I get the idea of presenting concepts in a more natural flow and smuggling in some spaced repetition, but the whole story just felt extremely forced and artificial to me, sort of like a drawn-out sequence of expospeak. There has to be a better way to include spaced repetition and discovery in teaching. Edit: Note this correction by Michael Nielsen: https://news.ycombinator.com/item?id=30325048 https://news.ycombinator.com/item?id=30325048
- deleted 5y ago[deleted]
- macintux 5y agoIf you think this is forced, you should read one of “The Easy Way” math books, like https://www.thriftbooks.com/w/barrons-trigonometry-the-easy-way_douglas-downing/391553/ https://www.thriftbooks.com/w/barrons-trigonometry-the-easy-... Fictional kingdom discovers Trigonometry out of necessity.
- marai2 5y agoTrigonometry The Easy Way, was brilliant! I wouldn't categorize it as forced in the manner of the OP. The book creates a fantasy backdrop to connect trigonometrical concepts in a fun way. I really enjoyed the book and it made trigonometry really stick in my brain!
- deleted 5y ago[deleted]
- renewiltord 5y agoHaha entertaining. I rather like this style. I skipped till the first code and then the interludes were short. But I think I would have been annoyed if the first code block was not demarcated clearly so I could skip to it. The prelude was too long for me to read since I didn’t know if there was going to be payoff.
- 5y ago
- macintux 5y agoPaul, there’s a typo in one code snippet where you show 128.0.0.3 instead of 127.0.0.3. Great article, enjoyed it.
- paulgb 5y agoFixed, thank you! (might take a bit to hit the CDN)
- sodality2 5y agoI absolutely love this writing style. Great article, thanks!
- cryptojanne 5y agoHorrible way to write, so many unnessecary words. Not for me.
- bravetraveler 5y agoI agree, but I know some people who like this style. Personally I want the gory technical details. This reads like those recipe sites that give you an unnecessary life backstory. The gore may be less approachable, but I'd say the overall effort to understanding the material is less.
- toyg 5y agoThe style can work. In this case it largely doesn't, mostly because the writer insists in trying to be cute about "Tim". Tim is a sockpuppet for the author, like Socrates in Plato's works. After the first couple of paragraphs, there is no point pretending he is anything but that. Trying to flesh him out, over and over through the text, is a waste of everyone's time.
- deleted 5y ago[deleted]
- dang 5y ago"Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something." https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- suction 5y ago"So many unnecessary words" to me is a good observation of the post's shortcomings, and ironically also applies to your comment.
- dang 5y agoIt isn't interesting to list the generic shortcomings of a post. We want curious conversation here. The moderation comments I post are for sure repetitive and tedious. The justification for them is not that they're interesting in their own right (they aren't! and they're even more tedious to write than to read). It's that without them, HN would be globally worse off. They're an out-of-band feedback channel forming one component of the system by which the forum regulates itself. You can compare them to medicine which is toxic but which one takes anyway because the alternative is worse. https://hn.algolia.com/?dateRange=all&page=0&prefix=false&sort=byDate&type=comment&query=tedious%20write%20read%20by:dang https://hn.algolia.com/?dateRange=all&page=0&prefix=false&so...
- dec0dedab0de 5y agoThat was fun, but more about Linux than ports in general. I was expecting something more along the lines of a computer checks the port of every incoming packet and if it matches something it is expecting it does something. Though this was much more interesting, and now I'm curious about even more specifics of how Linux handles this.
- btown 5y agoSee my top-level comment: https://news.ycombinator.com/item?id=30324520 https://news.ycombinator.com/item?id=30324520
- criticaltinker 5y agoHad to read quite a bit before getting to the core insight: > “So when you listen on a port, you’re really listening on a combination of a port, an IP, a protocol, and an IP version?” > “Yeah, unless you listen on all local IPs. And if you listen on all IPv6 IPs, you also listen on all IPv4 IPs, unless you specifically ask not to before you call bind.” > “Right. So the operating system must have, like, a hash map from a port and IP pair to a socket, for each combination of TCP or UDP, IPv4 or IPv6.”* > “To a list of sockets”, Liz corrects. “Remember how I could listen on more than one?” > “But it also has to handle listening on all ‘home’ IPs, and to be able to find a socket listening on IPv6 from an IPv4 IP.”
- NoWizards 5y agothanks for this summary (the lecture was pretty boring to me). As i understood it, the article explains what happens when you listen to same or similar combinations of a port-ip-protocol-whatever... but i didn't learn what does it mean to "listen" on a port. how does two programs communicate by this way?
- thaumasiotes 5y agoThe port number is one field in a TCP or UDP packet. When you listen, you register with the operating system (or whatever controls the network card, I guess) saying that you want a particular port. When a packet comes in (on the network card), it will be routed to you (on your socket) if it's addressed to you (by including a port number you're registered for). You can think of the port number as the second half of your IP address. As far as the networking goes, an IP address and a port number are basically the same thing. The port number is just the lower bits of the "combined IP address".
- Dylan16807 5y ago"and an IP version" is more of a matter of interpretation though. I'm pretty sure you can model that behavior in terms of binding to an IPv4 address and binding to its associated IPv6 address. Rather than binding to the same IP with different IP versions. And it's worth mentioning that IP doesn't have ports. You don't take a port and then divide it into TCP and UDP use. TCP and UDP each independently build their own version of ports.
- Wuzado 5y agoI absolutely love the writing style. Any other examples of blog posts written like that?
- teraflop 5y agoNot quite the same style, but I enjoyed "Designing an Authentication System: a Dialogue in Four Scenes". https://web.mit.edu/kerberos/www/dialogue.html https://web.mit.edu/kerberos/www/dialogue.html
- politician 5y agoHN favorite ‘Godel, Escher, and Bach’ is written in this style.
- buzzwordninja 5y agoThe Phoenix Project is a book about agile project management. It's written in a similar style. https://www.goodreads.com/book/show/17255186-the-phoenix-project https://www.goodreads.com/book/show/17255186-the-phoenix-pro...
- pcthrowaway 5y agoNot a blog post, but https://howdns.works/ https://howdns.works/ is a really brilliant (animated) webcomic explaining how DNS works through a story. Each panel has some title text as well.
- wonnage 5y agoI have to admit I'm not a fan of "discovery fiction" as presented in this post, but reading Michael Nielson's linked post and some of his examples (e.g https://michaelnielsen.org/ddi/why-bloom-filters-work-the-way-they-do/ https://michaelnielsen.org/ddi/why-bloom-filters-work-the-wa...) I think the idea is great if executed well. The goal isn't to embed information in meaningless dialogue, but to walk the learner through an entire thought process rather than just presenting the finished result. Or to use one of tech's favorite expressions, to construct an idea from first principles.
- btown 5y agoFor more technical detail, https://linuxjournal.rubdos.be/ljarchive/LJ/298/12538.html https://linuxjournal.rubdos.be/ljarchive/LJ/298/12538.html goes into a TON more detail on this, including simplified code for the implementation of the which-socket-should-receive-this-packet algorithm. TL;DR: - the OS maintains a hash map mapping port/IP/protocol/protocol-version to lists of sockets - there's a scoring algorithm that determines which socket wins, based on specificity of how the socket(s) were bound - if multiple sockets are bound with SO_REUSEPORT, things are routed based on a hash of the source/destination address/port, presumably so packets from a single client aren't split between different handlers - essentially, simple zero-backpressure load balancing - read the article for nuances of when and how to use this, especially performance considerations about pre/post fork - consider adding TL;DR segments like this, whether you're writing discovery fiction like the OP, or technical deep-dives like the link in this comment. Different readers will prefer different formats, but everyone benefits from having the option to consume an abstract before reading lengthy nonfiction prose!
- vbezhenar 5y agoHow does ICMP routing work? I always wondered about that. There's no port in ICMP, how does OS understand which ping executable receives ICMP echo replies.
- toyg 5y agoIf I read this [0] correctly, there is still a hashmap of sorts. [0] https://flylib.com/books/en/3.475.1.74/1/ https://flylib.com/books/en/3.475.1.74/1/
- zamadatix 5y agoICMP has an identifier field and a sequence number field, both exist to aid in matching requests with replies.
- vbezhenar 5y agoThanks. It seems that's not exactly correct. ICMP has type, code and checksum fields. Rest of data is type-specific. But echo-request and echo-reply types do have identifier and sequence fields indeed.
- squarefoot 5y agoI made extensive use of the SO_REUSEPORT flag a couple decades back to build agents that on the same machine would have their own UDP socket which received data from a local piece of software. Basically, by using that flag each socket received a copy of the buffer, so that each agent could act upon the contents ("is it for me? - if yes then read this field and act accordingly, otherwise ignore"). Very handy, despite all limitations of UDP. It allowed me to keep the code very tight and specific for every agent, although network buffer structures were all in common so upgrading the protocol to all agents was easy. With some adaptations, it worked both on Windows's POSIX stack and Unix.
- ww520 5y agoThis sounds very handy for broadcast within a box type of applications.
- robotresearcher 5y agoMy recollection of SO_REUSEPORT behavior is that it will deliver a datagram to one listener, rather than all of them. The kernel will distribute datagrams fairly between listeners over time, so none are starved. This makes it super easy to share load over multiple servers, but doesn't get the same datagram to multiple listeners. This seems to confirm: https://lwn.net/Articles/542629/ https://lwn.net/Articles/542629/ Maybe the exact behavior varies by platform. I've never used it on Windows.
- squarefoot 5y ago> Maybe the exact behavior varies by platform. Yes, that was the case. Also I probably confused SO_REUSEADDR, which in Windows is implemented quite differently, with SO_REUSEPORT. Anyway, I can confirm that on Windows (2000) I could open N programs whose receiving socket was bound on the same address:port and all of them would receive a copy of the transmitted datagram. If say I run 5 copies of the same agent, all of them would display the same data. Those were stand alone applications without any shared memory, so apparently the system made a copy of the buffer for each socket. I'm not sure however if I tested this particular behavior also under Unix, since I needed it only on the graphical interface, but on Windows it definitely worked.
- indigodaddy 5y agoMan, the author was listening closely to that conversation!
- helpfulclippy 5y agoAs soon as she opened a socket, the NSA captured the whole thing.
- indigodaddy 5y agoHah!
- andrewstuart 5y agoThe other interesting thing about ports is when you release it, it's not available again for some period of time like 60? 30? seconds.
- qwertywert_ 5y agoReally? I don't see that behavior when I last did socket programming, or testing with netcat?
- badwriter32 5y agoThis article had a fun, enjoyable writing style, thanks!
- electrondood 5y agoCMD-F "so" to find the TLDR
- timc3 5y agoStill doesn’t explain it. I guess it would take a book to get through exactly what is happening.
- alexk307 5y agoRight!? This just shows by example the basics of calling the socket syscalls via Python. I still do not know how these syscalls work or what it really means to be listening to on a port.
- enchiridion 5y agoInteresting divide on the writing style here. As a person who doesn’t do much networking, I appreciated the context. I wonder if the people who didn’t like the post style are networking experts who are already steeped in this stuff? Anyone care to comment if the fall into either group?
- ninth_ant 5y agoIt would be improved by changing the framing from a discussion to singular persons internal dialogue showing progression and train of thought. I’ve used this before in a work context to explain complex debugging issues. “Hmm that doesn’t work, what about X” <code> “Oh but that didn’t do what I wanted. What if we added Y and Z” <code>
- dmoy 5y agoI don't do much networking, and I found it difficult to parse information out of this.
- deleted 5y ago[deleted]
- foxfluff 5y ago> Anyone care to comment if the fall into either group? I know a thing or two about networking and didn't really learn anything new from the article. And I don't really like the style, but I don't feel like my expertise with networking plays much into it. Why didn't I like it? Hmm, first of all, I skipped the italic blurb and jumped straight in. So at first I didn't know I was reading fiction. It sounded like story time, as in a story of something interesting that actually happened, and for which you may need to give a bit of context.. I don't have a great example in mind but think something like the 500-mile email (https://www.ibiblio.org/harris/500milemail.html https://www.ibiblio.org/harris/500milemail.html). That's the kind of story I expected I was getting into. And then I was disappointed that there was no story. Once I got over that and looked back.. well, one obvious thing that's missing for me is motivation. “Yeah, I know that, but how?” Liz says. Why does she care? Why should I care? I immediately got the same vibe that I get when I come across someone with an X-Y problem and they're the stubborn kind who refuse to explain why or what they're actually trying to find out. Or when I come across someone who's curious but trying to pass the burden onto someone else (kinda like a help leech except that they don't even have any concrete problem they need help with). It wouldn't be the first time I've said on IRC something like "Sorry, I don't know. If you really want me to read the kernel code for you and tell you how it works, I might do that later tonight but I figured you could satisfy your own curiosity." Someone wants to know something but there's no real motivation for the next person to care. I guess I kinda feel how I imagine Tim feels: he can guess what the OS might be doing, but he doesn't have motivation to find out more. And then there's the fiction-fluff that doesn't really do anything for me. Liz and Tim aren't interesting, there's not much personality, and even if they had personality, there's not much reason to care; they're just random nobodies. The setting isn't interesting. I don't care if there's a coffee shop because the coffee shop also isn't a key element of the story; arguably, there are no key elements. There isn't anything exciting going on, Liz just wants to know how Linux demultiplexes TCP and UDP. So all the fluff feels superfluous and forced. It could work if there was an interesting story. A reason to build something, a reason to find something out, a reason to poke the kernel around a bit. And in that case, you wouldn't need so much "fluff"; the narrative could support and enrich the story (explain things and continue to add motivation) rather than just pad it. Writing that sort of educative story is really hard though.
- jollybean 5y agoIt'd be ideal to have a very succinct and clear 3 sentence articulation. Followed by maybe a couple of examples. If we're exploring the mysteries of the Universe, stories help, but our own arbitrary creations? They are just tools. They should be simple, robust, anti-complex and as mundane as we can make them. T
- htk 5y agoIt would be your ideal. Nothing is keeping you from writing it the way you suggested.
- elcapitan 5y agoThis is horrible to read. I gave up after the first screen page. When I'm trying to extract knowledge from a post or an article, I don't want it padded with useless prose that I need to skip when parsing the text. Like an invasion of this fluff style of "long read" that has become fashionable in what used to be journalism.
- jsiaajdsdaa 5y agoYou would love recipe blogs then!
- accrual 5y agoInterestingly, the life stories surrounding recipes may be a form of copyright protection. > In the U.S. copyright law doesn't protect "a mere listing of ingredients," but "where a recipe or formula is accompanied by substantial literary expression in the form of an explanation or directions... there may be a basis for copyright protection." This is from an article about a tool developed to extract recipes from their blogs: https://www.eater.com/22307633/why-are-people-mad-at-recipeasly-recipe-blog-criticism https://www.eater.com/22307633/why-are-people-mad-at-recipea...
- deleted 5y ago[deleted]
- GeorgeTirebiter 5y agoDoes anybody else dislike the socket interface abstraction? To me, an individual TCP port + IP is, effectively, giving me a 'virtual uart'. Instead of saying COM4 or whatever, you say tcp port 12345 IP address 6.7.8.9 Similar thing for ranges of IP address, except in that case, the 'listener' has to figure out which 'virtual uart' to act upon. In that case, the OS splits the 'virtual uart' assignment with the server listening to a range of address. Sockets seem unnaturally messy to me. Maybe I'm ignorant.
- hongsy 5y agoWhat is a virtual uart?
- PaulDavisThe1st 5y agoThe COM4 endpoint only exists inside that one computer. There is one, and only one COM4 in that one computer; anybody who wants to read or write from/to it knows how to identify it. A socket is reachable from other computers, so it must have a network address of some kind associated with it. The process that owns the port may want to refuse connections from another computer, so there has be a step in which the receiver accepts an attempted connection. COM4 can essentially never reject either a reader or a writer.
- xorvoid 5y agoYes. It is bad. And it’s warped programmer brains for decades now. If you want to have some fun and design a better interface, go grab a direct kernel-bypass layer 2 NIC interface and learn how much better things could have been. Unfortunately, the sockets api isn’t going away. But, on the positive side, it’s one of the most portable OS interfaces out there.
- pclmulqdq 5y agoI switched from hardware engineering to software engineering, and the socket abstraction (as well as the TCP bytestream abstraction, which appears to have been part of the inspiration for how sockets work) seemed absolutely nuts to me. Kernel bypass style queues make a lot more sense from first principles.
- thayne 5y agoIt talks about mapping a port (and ip address, and protocol) to a process, but on Linux (and I think other unixes as well) that isn't quite accurate. It maps to a file descriptor, and that file descriptor can potentially be share with other processes (for example by forking, or passing it over a unix domain socket). One common way this is used is to pass a socket file descriptor from the old process to the new process when restarting a service.
- bryanrasmussen 5y agoand here I always thought it was a nautical term from the days of Francis Drake when most sailors were also spies for their respective countries. Kit Marlowe was listening on a port down by his favorite tavern, planning on skipping out on bail, when he was knifed to death.
- parentheses 5y agoGreat article! The storytelling style, however is very difficult to skim. It really requires reading dialogues and actions.
- trulyme 5y agoIt is however a joy to read, at least for me. Kudos to the author!
- aunty_helen 5y agoIf you're looking to skim for answers, this probably isn't the resource you would come across. However, it's a Sunday afternoon, raining and there's thunder in the background. It's the perfect style to relax and enjoy.
- chanux 5y agoI too wanted to just skim. Just read what's around the code blocks.
- freetime2 5y agoThis article really left me wanting to learn more… about the budding relationship between Tim and Liz. Maybe in the next chapter Tim can confess his feelings for Liz while they learn together about Unix Domain sockets?
- deleted 5y ago[deleted]
- imwillofficial 5y agoI applaud the author’s attempt to dig into an important and fundamental question often overlooked. But this was such obtuse writing that was painful to read. I recommend a less clunky narrative based format.
- qwertox 5y agoFor me SO_REUSEPORT was only a solution to be able to immediately reuse a port when a process crashed in some odd way and the OS was not releasing the port immediately. When I read that multiple processes can use the port it finally made sense to me how nginx is able to spawn so many workers. If they are listening to port 80 or 443 with SO_REUSEPORT, each worker would get a new client in a round robin fashion, effectively spreading the workload without depending on the main parent process to pipe the data to them (and back to the client), which is how I thought that it was working. The funny thing about this submission was that when I read the title I somehow thought I was reading it on Stack Overflow and was expecting a noob asking this question and didn't know what kind of answers I was about to be confronted with and if I should get excited to see a really good one. Then, while in the article, I liked how it started to raise so many issues, fanning out into these special cases which really made it a valid question to ask what it does mean to listen to a port, how complicated it can become. Sadly the article does not go into any detail, like showing snippets of C code from the networking stack and explaining how it is really working, how each requirement (or kluge, for that matter) is being satisfied, but it's OK, it's an article which touches the subject in an enticing enough way while having an excuse to not deep-dive into the details by keeping it in the form of a dialog between two students. I liked it.
- y04nn 5y agoThere is data piping needed between the main thread and workers, each new connection is handled to a worker as a socket descriptor, like a pointer.
- moltenguardian 5y agoAre you referring to SO_REUSEADDR?
- userbinator 5y agoIt seems this style of writing is quite divisive, but those who liked it may also enjoy The Manga Guide series: https://news.ycombinator.com/item?id=30120927 https://news.ycombinator.com/item?id=30120927 There doesn't seem to be a Manga Guide to TCP/IP yet. Personally, it's divisive for me too --- if I'm looking for specific information, this gets in the way; if I'm looking for "edutainment", then it fits.
- Closi 5y agoI think this style of writing can work - but it works best if the story is something other than two people just talking about 'how do you think this thing works?'. Like if you can pick any story, why make it about two people in a study hall, studying and directly asking each other the question? It could be a story about some rogue hackers, international spies, or the characters could be ducks rather than humans, or you could tell it from the perspective of a sentient computer or application... So if you are going to make it into a fictional story, you might as well make it a fun fictional story (either by the premise or by a character!).
- reilly3000 5y agoI think that the process of discovery is engaging, and far more relatable than a man page. Maybe the prose went a little further than it needed to, or as you suggest not far enough. I’m just saying that the mechanism of storytelling exploits some attributes of our evolutionary biology that make learning a concept more relatable and memorable.
- Closi 5y agoI agree with the process of discovery - but would personally prefer that to be communicated in the first person (which I personally find clearer and more enjoyable to read). As in telling the true story which is probably “I wondered how ports work, then I did this, then I wrote this script, then it had an unexpected result”, which still reads as discovery to an audience (but is the authentic and true story). IMO Readers will find a true story interesting if told with authenticity and passion. For fiction, you generally need ‘an ununsual thing’ in the story that happens that breaks it away from normality. I think this treads the awkward space inbetween - it’s made up (so no authenticity) but that authenticity isn’t replaced by something ‘unusual’ that drives the story forward. > Maybe the prose went a little further than it needed to, or as you suggest not far enough. I think this is right - although I don’t think there is a happy medium between those points. I think you can go in either direction (further or less), but straddling the middle is the tough bit.
- account-5 5y agoI've no real knowledge of networking, I read this and have no idea what it's actually trying to teach. I say teach because I have read comments hear about it teaching but I can't actually speak to that. I am still as lost at the end as I was at the start, probably more so.
- dreamcompiler 5y agoThe article is aimed at low-level network programmers. I learned the subject from Stevens [0] which is quite old but is still one of the standard references. [0] https://www.amazon.com/UNIX-Network-Programming-Richard-Stevens/dp/0139498761 https://www.amazon.com/UNIX-Network-Programming-Richard-Stev...
- carlmr 5y agoI'm wondering if there's a good summary of this somewhere. 784 pages seems a bit much to get to know the basics of networking. Maybe it IS that complicated, but I'm wondering if it's worth it for me as a developer that only sometimes touches on these issues, to read through it.
- jmchuster 5y agoUnderstanding networking is basically a "superpower" of sorts for programmers.
- foxfluff 5y agoIt's not that complicated. For a basic TCP socket application, you need a couple dozen lines of code. Explaining how it works isn't going to require a 1000 page book. Of course networking and network programming is a deep topic, but IMO once you get the basics down, you're soon at the stage where "you'll know it if you need it" w.r.t. more advanced stuff and can learn it on demand. I skimmed that book and it does go quite deep, but also has lots of asides into C programming and Unix in general. For example, at one point it introduces you to the idea of wrapper functions to simplify error handling. This has nothing to do with socket programming or networking. There's BSD networking history, which might not be worth your time. There's introduction to Unix commands that are outdated if you're on Linux, but "be aware that some vendors place these commands in an administrative directory, such as /sbin". There's a section on Unix standards; would you like to know what POSIX stands for? Would you like to know about 64-bit architectures? Would you like to learn about memset() and memmove(), or fork() and exec()? How about fcntl() and close(), or posix signal handling, or waitpid()? Here let me introduce you to select() and poll() and nonblocking i/o. And pthreads... It's by no means a bad book but it's about "Unix" and "(C) programming" almost as much as it is about network programming. Depending on your background that may or may not be a bad thing but I prefer materials with narrower focus.
- pdimitar 5y agoI've read the whole thing patiently even though I am not sold on the format of such stories -- but it was still informative. The only thing I thought at the end was: "yeah, the whole thing should be torn down and redone from scratch". Which of course isn't ever happening, right?
- cgreerrun 5y agoWith a little formatting to make it feel like a fiction book, the writing style works much better for me: https://imgur.com/a/5R3x2BL https://imgur.com/a/5R3x2BL Love the article and the writing style! /* CSS changes for fiction book style: */ .postbody p::first-letter { margin-left: 18px; } .postbody p { text-align: justify; hyphens: auto; line-height: 29px; font-family: Georgia; max-width: 683px; margin-top: 1px; margin-bottom: 0px; }
- mastax 5y agoWould be interesting to A/B test if this formatting reduced the number of HN complainers about brevity.
- exikyut 5y agoThat would require multiple submissions, or a fairly comprehensive bit of API tooling :/
- chrismorgan 5y agoFeedback on the specific CSS techniques employed: • Instead of `.postbody p::first-letter { margin-left: 18px }`, probably use `.postbody p { text-indent: 18px }`. (Admittedly text-indent has the downside that it is inherited by any block or inline-block children, so caution is required. Y’know, maybe in the general case ::first-letter margin-inline-start is actually handier when you’re deliberately just applying it to paragraphs, so you don’t need to worry about potential block children or inserting a `p > * { text-indent: 0 }`.) • `hyphens: auto` will generally do nothing unless the document declares its language (which this one doesn’t), e.g. <html lang="en">. As for whether you want it anyway… eh; greedy line-breaking (which is all that any browser implements at this time) and hyphenation don’t go particularly well together, you end up with significant quantities of gratuitous and unhelpful hyphenation. • `font-family: Georgia` is unwise, as you can’t depend on people having Georgia. (Windows should, but other platforms probably won’t, though some may alias it.) You should certainly include a fallback of `serif`. (And in this specific case, the site is already using a serif, is Georgia even worth changing to?) • Some of the numbers are a bit odd, but I’m guessing that’s because you just implemented it in dev tools and copied it verbatim. Me, I’d use em for the text-indent (and a larger value, at that, probably 1.2–1.4em), unitless for line-height (e.g. 1.5, which is a smidgeon more), em for max-width (though if the whim took me, I might devolve to ch occasionally), and 0 for margin-top and margin-bottom (or possibly 0.5em—half a line or so actually works quite nicely on a scrolling-based medium, though I wouldn’t do it on a paginated screen or any but the thickest double-sided paper).
- tonymet 5y agoi guess engineering blogs have gone the way of recipes.
- jll29 5y agoWell done - thanks. A good dialogue, reminds me a bit of those written by Plato (okay, apart from the difference in topic); I wish I had more inquisitive students like Liz.
- antod 5y agoAlso reminds me of this Kerberos one: http://web.mit.edu/kerberos/dialogue.html http://web.mit.edu/kerberos/dialogue.html (Edit: someone else already posted that further down - doh)
- inopinatus 5y agoIf a packet hits a pocket on a socket on a port, And the bus is interrupted as a very last resort, And the address of the memory makes your floppy disk abort Then the socket packet pocket has an error to report! — Gene Ziegler, "A Grandchild's Guide to Using Grandpa's Computer" (1994)
- deleted 5y ago[deleted]
- knicholes 5y agoThis feels a lot like the paddle battle in Fox in Socks.
- WaitWaitWha 5y agoI think the 'port' concept inherits so much abstraction, it changes the meaning and how it really works. When I started out, a port was (and still is) just a designated memory location, and address, where some process (like a NIC driver) can write byte(s) into it. 'Listening' on a 'port' just meant the memory location is checked by a piece of code either through polling or interrupt driven. The interrupt is triggered by the same process that placed the data into the mem location. Abstraction married to time is a is the enemy of knowledge.
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- codeisawesome 5y agoThank you so much for confirming this - I always wondered whether that's all it actually meant beyond the abstraction. TFA doesn't actually explain it despite the title(!)
- batisteo 5y agoYour comment is what I was looking for in the article – it answer the question!
- IgorPartola 5y agoI suspect the concept of port might not have been needed had we started with IPv6. As it currently stands we allocate each physical host a /64. That would mean that even if we by default used port 1 or whatever we would basically never run out of possible service end points. An IP address + port is just a way to multiplex an address. It is kinda fun to work directly at IP level and not use TCP or UDP at all. I highly recommend giving it a try.
- bscphil 5y ago> It is kinda fun to work directly at IP level and not use TCP or UDP at all. Possibly dumb question: if you're not using ports (because you're not using TCP at all), what does routing look like, in terms of this article? How does the kernel decide which traffic goes to application A and which traffic goes to application B? Or is all traffic directly visible to each application, if they aren't bound to a port? Can you bind to a specific IP, or just to an interface?
- YarickR2 5y agoThere are many more questions besides you've ready asked; basically, who or what is providing TCP-like transmission reliability and synchronisity, who's doing ICMP , who's doing fragmenting, and why does one need to reimplement better part of the stack
- simiones 5y agoThe normal way to "work directly at IP level" (or even below) is to use a RAW socket. The kernel will deliver all traffic matching the IP (or other things - raw sockets can essentially own the whole NIC) to your socket, and from there it's all up to you. The kernel will only look at the IP headers, the rest of the packet (TCP/UDP headers specifying ports, for example, if any) will be delivered to the raw socket. Not sure of the implementation details, but in principle the same logic about specificity of socket binding could be done by the kernel when deciding which socket to actually send the data to. Any other logic (CRC validation, packet ordering, confirming packets have been received, MSS etc.) are all disabled, you just get the raw packet as it was received on the wire, based on the IP headers (an the same happens when you send a packet on a raw socket).
- josephg 5y agoI’m gonna come out and say it: I think ports were a mistake in TCP. It makes way more sense to think of an IP address as the entire “address”+port tuple. When you look at it like that, so many aspects of computer networking get simpler. First, we think of every computer on a network as having a range of addresses - usually 65536 of them. But that’s an arbitrary choice that could be adapted in lots of ways. Every connection directly connects two IP addresses - which is way simpler than what we do now. DNS should associate a name with an address - including what we currently call the port. That way we wouldn’t need special application specific port assignments. And then we wouldn’t need SNI and all that - because computers could have a bunch of fully process-isolated web servers, just listening on different incoming address+port tuples. Obviously we can’t change tcp/ip, but parts of the tcp/ip infrastructure already work this way - but we’re lacking the language to talk about it.
- bathtub365 5y agoThis explanation doesn’t sound simpler at all, it sounds like the complexity (each computer runs multiple services) is just obfuscated by making it part of the IP address. It would make routing a nightmare since the router now needs to keep a table of all services running on all hosts to know where to route traffic.
- sleepydog 5y agoRouting would be no different. Routers already work with IP address prefixes. In the scheme described, a computer's IP is just a /32 prefix of a 48-bit address, and serves as the router for the 65k addresses.
- zarzavat 5y agoIsn’t that what we have now with addresses and ports? What’s the difference?
- josephg 5y agoThe biggest difference is language - we don't have to think about addresses and ports being different ideas. Our APIs and textbooks get simpler. And from an address perspective, its better because we end up with much more flexibility around how our networks are designed. Want to use 1 public IP address with 10k web servers? Now you can! Want a single machine to handle 10M outgoing socket connections? Sure - just allocate more addresses from your pool. You can already do some of this stuff right now, but its awkward to reason about because of how ports and addresses interrelate. It'd be simpler and easier if we just think of the (address,port) tuple as a single address entity.
- ohazi 5y ago> Tim’s attention turns to the code, and he puts his finger near the screen to read over it. Liz, who hates a smudged screen, says “easy there!” and pushes his hand back. “I wouldn’t touch it”, he protests. Making an exaggerated show of keeping his hand a safe distance back, he points to the [...] Okay, that was pretty good. I've long since lost track of the number of times I've had this exact exchange.
- gbog 5y agoI was very interested by the question, and closed the page after skimming through the first screen: why is there any need to scenarize? why would I want to read about some guys in a bar? Can't we make it interesting to talk about what it really means for a device to "listen on port x"? In my experience (listening to Collège de France podcasts), any topic, even the most obscure and narrow field of knowledge, say "Late Babylonian scriptures as seen by Ibn Amhoud during 8th Century" (invented), can be made a thrilling experience if the speaker is really passionate and knowledgable about it. But there is never any need to start by a conversation at starbucks: one just dive in head first. </rant>
- voidfunc 5y agoSo on one hand, I absolutely hated the writing style as well... on the other hand, its some guys blog and if he likes this style and it makes him happy to write educational stuff like this, even if its not an ideal format for us then should we really judge?
- ohashi 5y agoBecause different people learn differently? This style reminded me of GEB a bit and I enjoyed it.
- Barrin92 5y agoBrings to mind Elements of Style. Place yourself in the background, don't overwrite, don't overstate "Write in a way that draws the reader's attention to the sense and substance of the writing, rather than to the mood and temper of the author. If the writing is solid and good, the mood and temper of the writer will eventually be revealed and not at the expense of the work. Therefore, the first piece of advice is this: to achieve style, begin by affecting none — that is, place yourself in the background."
- semitones 5y agoI agree that it is probably not the optimal way to write an educational piece. However, in our year of 2022, the amount of content available online is absolutely staggering. If there weren't at least some pieces out there that tried to scenarize concepts like this, I would be disappointed - it's an experiment worth attempting.
- tomerbd 5y agoLove the writing style. Much more amusing to read and learn.
- buzzard1 5y ago
- deepsun 5y agoWhen did it become normal to waste readers' attention on technical articles: "In the corner of the student union building there is a coffee shop, and in the corner of the coffee shop are two students. Liz taps away at the keyboard of the battered hand-me-down MacBook her brother gave her when she moved away to college. To her left on the bench seat, Tim scrawls equations on a coil-bound notebook. Between them is a half-empty cup of room temperature coffee that Liz sporadically sips from to stay awake. Across the room, the barista looks up from his phone to glance around the shop. ..."
- suction 5y ago"'No', our main character Tim, a computer science major from Ontario, the capital of Ottawa, Canada, mystifiedly said, shrugging his broad, well-toned shoulders." If he was a good writer, maybe he could have made it work. But this reads like a "write what you did yesterday" assignment handed in by a 12 year old. If even.
- srigi 5y agoExactly. After first sentence I immediatelly switched into "scan mode". I was'nt able to find the answer for the question in the title. I was even not able to identify a section where the answer could be burried in.
- dTal 5y agoRead it, or don't. It's unfair to the author to complain because your "scan mode" is inadequate.
- paulgb 5y agoIt was the weekend, and I had fun writing it. Nobody is forcing you to read it. But I'm certain that if I wrote it in the style you wanted me to write it in (which is how I write most of the things I write!), you never would have seen it :)
- deepsun 5y agoOf course, just as nobody is forcing you to read my complaints :) > you never would have seen it On the contrary -- I clicked it only because of the title. But I stopped reading after the first paragraph, so I still don't know what does it mean to listen on a port, exactly because of the style, too bad for me. :) But I strongly support your right to write any style you want, I'm avid supporter of authors' "right to burn".
- deleted 5y ago[deleted]
- WC3w6pXxgGd 5y ago