News for hackers. Stuff that matters.
Re:Hooray for the Sockets Interface by asveikau on Wednesday July 29, 2026 @12:19AM (#49093375)
I disagree with this. Separating lookup from connect(2) or sendmsg(2) is cleaner. If an application doesn't care about the difference, most people are using higher level APIs built on top anyway, and most of those will provide a quick way to hide DNS details from you.
Re:Hooray for the Sockets Interface by UltraSane on Wednesday July 29, 2026 @01:19AM (#49093672)
https://blog.ipspace.net/2009/08/what-went-wrong-socket-api/

A DNS name can have a LOT of A records associated but a socket has to pick one. This is a severe limitation.

Re:Hooray for the Sockets Interface by drdexebtjl on Wednesday July 29, 2026 @01:45AM (#49093817)
A socket has to pick one, but your application doesn’t.

You can hedge your bets and open a connection and send data to _all_ of them, and pick whichever returns faster.

This of course requires you to know about the application-layer protocol.

For HTTP, you need to restrict this strategy to GET methods, for example.

Hence why it can’t be part of the socket interface.

You can always build higher level abstractions on top of sockets if you need them.

Re:Hooray for the Sockets Interface by cyberax on Wednesday July 29, 2026 @04:46AM (#49094879)
You absolutely can establish multiple TCP connections for POST methods. You just can't send any _data_.

This is even used by browsers, this trick even has a slightly creepy name: "Happy Eyeballs".

Re:Hooray for the Sockets Interface by drdexebtjl on Wednesday July 29, 2026 @10:50AM (#49098300)
That’s true for HTTP.

TCP does not require that the act of connecting must be pure, so you cannot indiscriminately apply Happy Eyeballs at the socket API level.

Re:Hooray for the Sockets Interface by zbentley on Wednesday July 29, 2026 @11:36AM (#49098899)
I suppose, but the number of applications for whom a successfully-negotiated bare socket connection (with no TLS or data exchanged) is side-effectful to the point that this causes problems is pretty darn small. I'm sure there are some terrifying counterexamples, but they have to be part of a tiny minority, right?

More concerning is the risk of exhausting server socket resources when probe-based connects don't hang up quickly if they don't want to use a connections. Lots of servers/load balancers aren't well-tuned to force-close connections if the first byte doesn't arrive within a short time.

Re:Hooray for the Sockets Interface by drdexebtjl on Wednesday July 29, 2026 @01:05PM (#49100128)
I agree. But we couldn’t have possibly guessed this in the 80s.

Instead we converged on a very simple primitive that makes no such assumptions and can be composed into a wider variety of high level abstractions in user space.

Re:Hooray for the Sockets Interface by cyberax on Wednesday July 29, 2026 @05:17PM (#49103211)
> More concerning is the risk of exhausting server socket resources when probe-based connects don't hang up quickly if they don't want to use a connections.

TCP connection cookies solved this problem in 90-s! They fell out of use because dedicating a couple MB of RAM to track a few hundred thousand connections is not a big deal anymore.

Re:Hooray for the Sockets Interface by inigyou on Wednesday July 29, 2026 @07:07PM (#49104257)
Linux will still revert to cookies when exceeding a certain number of half open connections, preventing DoS.
Re:Hooray for the Sockets Interface by cyberax on Wednesday July 29, 2026 @02:41PM (#49101344)
That's theoretically true. But I don't know any public Internet-facing apps that care about that.

For non-public networks, sure. For things like TCP-to-RS232 connectors that can only service one connection at a time. Happy Eyeballs needs to be disabled for them, but that's just one socket option.

And if the Happy Eyeballs protocol was standardized earlier, these kinds of apps arguably would have adapted to it.

Re:Hooray for the Sockets Interface by jruohonen on Wednesday July 29, 2026 @01:32AM (#49093750)
> This is a severe limitation.

Rather, it is a feature.

Re:Hooray for the Sockets Interface by UltraSane on Wednesday July 29, 2026 @09:02AM (#49096975)
How so?
Re:Hooray for the Sockets Interface by jruohonen on Friday July 31, 2026 @09:43AM (#49123054)
> How so?

Standards as well as all manual pages and other documentation say that getaddrinfo() should be called via a loop by clients. And results show that almost all clients indeed do that. Therefore, on the server-side, you can do round-robin DNS, randomization (as suggested by the post linked), fall-backs, CDN things, and many other things.

Re:Hooray for the Sockets Interface by UltraSane on Saturday August 01, 2026 @08:35AM (#49133899)
Standard TCP maps connections to IP addresses. If your IP changes, the connection drops. A secure cryptographic Session Layer maps connections to your unique device ID. Imagine if the functionality of something like tailscale was actually built into TCP/IP. This is what the missing session layer should have been.
Re:Hooray for the Sockets Interface by zbentley on Wednesday July 29, 2026 @11:33AM (#49098852)
I'd actually say that the original sin of the socket API was taking DNS in higher-level connect methods at all. Users should have to separate the act of address lookup from the act of opening a connection every time (and could write the 5loc utility function to hide that split if they want).

I say that not out of purity concerns, but because of how DNS and TCP work. DNS multirecord selection (or not) should be up to the user. DNS timeouts should be surfaced granularly and differently from e.g. TCP SYNACK timeouts. Once a TCP stream is open, if a novice user opened it conceptually to a domain rather than an address, there's no intuitively correct answer to what happens if the domain's resolution changes while the socket's connected.

Re:Hooray for the Sockets Interface by inigyou on Wednesday July 29, 2026 @07:06PM (#49104249)
When it was written I don't think they had DNS. Maybe they had hosts files maybe not.
Re:Hooray for the Sockets Interface by asveikau on Wednesday July 29, 2026 @12:03PM (#49099258)
Imagine if handling that were a kernel feature completely hidden from you and there was no way to replace it in user mode, or even have visibility into its failure modes. I'd say that's worse.
Re:Hooray for the Sockets Interface by UltraSane on Wednesday July 29, 2026 @12:11PM (#49099389)
Telling the socket the IDENTITY of the host you want to reach and abstracting away all the details of how to reach it is exactly what the missing TCP/IP sessions layer is supposed to do. By tightly coupling the session layer to explicit Layer 3 network routing parameters (IP addresses), the classic socket API failed to separate a host's identity from its physical location.
Re:Hooray for the Sockets Interface by asveikau on Wednesday July 29, 2026 @12:20PM (#49099501)
Questions of identity are established at a higher level in user mode by TLS. Pushing all that into the other side of the kernel interface again seems not great.
Re:Hooray for the Sockets Interface by UltraSane on Wednesday July 29, 2026 @01:53PM (#49100744)
https://en.wikipedia.org/wiki/Locator/Identifier_Separation_...

I've used this in networks and it enables amazingly easy endpoint mobility.

Re:Hooray for the Sockets Interface by tremon on Wednesday July 29, 2026 @08:43AM (#49096763)
It's not just about separating lookup and connect: the fundamental stream abstraction is a point-to-point connection. It's possible to construct one-to-many connections on top of that, but it adds a lot of complexity on both sides. Doing it the other way around (emulating one-to-one connections on top of a one-to-many abstraction) means burdening simple connections with a lot of unnecessary complexity.