3 ms·
If you use 0 for the port, the Linux kernel will assign you a random port.
by tristan957 3y ago
If you use 0 for the port, the Linux kernel will assign you a random port.
- rwmj 3y agoIt's more of a coordination problem. Even if the web server could be persuaded to use port 0 (most will barf at this), I now have to find out what port was assigned by the kernel and communicate that to the test client. Unix domain sockets just make this whole problem go away. Also running out of ports is a thing! There are only 64K ports (with many not being usable) and a CI machine might be running many tests in parallel. Unix domain sockets give me an infinite space of ports, since they use filenames.
- tristan957 3y agoIt isn't infinite space. The buffer for filenames is only 256 bytes, so 255 including the NUL terminator. But still, that is a ton more socket names than ports.
- yencabulator 3y agoYou can have arbitrarily complex names because filesystems are a tree, not a flat namespace. The limit you'll hit is either inodes or kernel memory, neither of which will run out all that easily.
- monocasa 3y agoThat's not just Linux, that's a more global IP sockets thing.