Networking
Bind to an ephemeral port and read it back with getsockname
Bind to port 0 so Linux picks a free port, then read the chosen number with getsockname() and ntohs() on glibc 2.39. Useful for tests.
1 min read
Short posts that solve one thing: the code, the output we got, and why it works.
Bind to port 0 so Linux picks a free port, then read the chosen number with getsockname() and ntohs() on glibc 2.39. Useful for tests.
Create an IPv4 TCP socket with socket(AF_INET, SOCK_STREAM, 0) on Linux with glibc 2.39, check for -1, and see why the protocol argument can stay 0.
We send one email when a new post is published. No spam.