IP_BIND_ADDRESS_NO_PORT(2const)

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

History

Linux 4.2.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.