IP_BIND_ADDRESS_NO_PORT2const
Don't reserve an ephemeral port
Usage
#include <netinet/in.h> /* Definition of IP* constants */ #include <sys/socket.h>
int setsockopt(int sockfd, IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, const int *enable, sizeof(int));
Library
Standard C library (libc, -lc)
Overview
Inform the kernel to not reserve an ephemeral port when using bind(2) with a port number of 0. The port will later be automatically chosen at connect(2) time, in a way that allows sharing a source port as long as the 4-tuple is unique.
Errors
See IPPROTO_IP(2const). See setsockopt(2). See ip(7).