Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ The AF_* and SOCK_* constants are now :class:`AddressFamily` and
MSG_*
SOL_*
SCM_*
IP_PORTRANGE*
IPPROTO_*
IPPORT_*
INADDR_*
Expand Down Expand Up @@ -827,6 +828,17 @@ The AF_* and SOCK_* constants are now :class:`AddressFamily` and

.. availability:: not WASI.

.. data:: IP_PORTRANGE
IP_PORTRANGE_DEFAULT
IP_PORTRANGE_HIGH
IP_PORTRANGE_LOW

These constants are available for manipulating port ranges on a socket-level
as opposed to system-level.

.. availability:: BSD, Linux.
.. versionchanged:: 3.15

Functions
^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add the ``IP_PORTRANGE*`` constants to :mod:`socket` on supporting systems.
14 changes: 14 additions & 0 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8728,6 +8728,20 @@ socket_exec(PyObject *m)
ADD_INT_MACRO(m, SYSPROTO_CONTROL);
#endif

/* Unix-specific macros for setting IP port ranges. */
#ifdef IP_PORTRANGE
PyModule_AddIntMacro(m, IP_PORTRANGE);
#endif
#ifdef IP_PORTRANGE_DEFAULT
PyModule_AddIntMacro(m, IP_PORTRANGE_DEFAULT);
#endif
#ifdef IP_PORTRANGE_HIGH
PyModule_AddIntMacro(m, IP_PORTRANGE_HIGH);
#endif
#ifdef IP_PORTRANGE_LOW
PyModule_AddIntMacro(m, IP_PORTRANGE_LOW);
#endif

/* Some port configuration */
#ifdef IPPORT_RESERVED
ADD_INT_MACRO(m, IPPORT_RESERVED);
Expand Down
Loading