| 1 |
.\" Copyright, the authors of the Linux man-pages project |
| 2 |
.\" |
| 3 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 4 |
.\" |
| 5 |
.TH IP_BIND_ADDRESS_NO_PORT 2const 2025-11-25 "Linux man-pages 6.18" |
| 6 |
.SH NAME |
| 7 |
IP_BIND_ADDRESS_NO_PORT |
| 8 |
\- |
| 9 |
don't reserve an ephemeral port |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.BR "#include <netinet/in.h>" " /* Definition of " IP* " constants */" |
| 16 |
.B #include <sys/socket.h> |
| 17 |
.P |
| 18 |
.BI int\~setsockopt(int\~ sockfd ,\~IPPROTO_IP,\~IP_BIND_ADDRESS_NO_PORT, |
| 19 |
.BI " const\~int\~*" enable ,\~sizeof(int)); |
| 20 |
.fi |
| 21 |
.SH DESCRIPTION |
| 22 |
Inform the kernel to not reserve an ephemeral port when using |
| 23 |
.BR bind (2) |
| 24 |
with a port number of 0. |
| 25 |
The port will later be automatically chosen at |
| 26 |
.BR connect (2) |
| 27 |
time, |
| 28 |
in a way that allows sharing a source port as long as the 4-tuple is unique. |
| 29 |
.SH ERRORS |
| 30 |
See |
| 31 |
.BR IPPROTO_IP (2const). |
| 32 |
See |
| 33 |
.BR setsockopt (2). |
| 34 |
See |
| 35 |
.BR ip (7). |
| 36 |
.SH HISTORY |
| 37 |
Linux 4.2. |
| 38 |
.\" commit 90c337da1524863838658078ec34241f45d8394d |
| 39 |
.SH SEE ALSO |
| 40 |
.BR IPPROTO_IP (2const), |
| 41 |
.BR setsockopt (2), |
| 42 |
.BR ip (7) |