logoalt Hacker News

drdexebtjltoday at 5:45 AM1 replyview on HN

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.


Replies

cyberaxtoday at 8:46 AM

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".