You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set to 1 to enable sending of keep-alive packets on certain types of
sockets.
.. Availability: Linux, Windows
.. data:: SO_DONTROUTE
Indicates that packets sent through this socket should be routed
through the interface it is bound to.
.. Availability: Linux, Windows `(non functional) <https://msdn.microsoft.com/en-us/library/windows/desktop/ms740532(v=vs.85).aspx>`_
.. data:: SO_BROADCAST
This option may be set to 1 to enable broadcasting messages, if
supported by the protocol. Note that IPV6 (:const:`AF_INET6`) does
not support broadcasting.
.. Availability: Linux, Windows >= Vista.
.. data:: SO_USELOOPBACK
.. Availability: FreeBSD, Windows >= Vista `(non functional) <https://msdn.microsoft.com/en-us/library/windows/desktop/ms740532(v=vs.85).aspx>`_
.. data:: SO_LINGER
When a socket is set to linger, a call to :meth:`~socket.close` or
:meth:`~socket.shutdown` will not return until all queued messages
for the socket have been successfully sent or the linger timeout
is reached. If the socket is closed due to the program exiting, it
will linger in the background.
The value for this option is a struct on most operating systems.
Consult your OS documentation for the struct's details.
.. Availability: Linux, Windows
.. data:: SO_OOBINLINE
Allows receiving of out of band data in the normal stream.
.. seealso::
`Out-of-band data <https://www.ibm.com/support/knowledgecenter/en/ssw_i5_54/rzab6/coobd.htm>`_
for an in depth explanation.
.. Availability: Linux, Windows
.. data:: SO_REUSEPORT
.. Availability: Linux >= 3.9 (for TCP/UDP)
.. data:: SO_SNDBUF
SO_RCVBUF
Sets the size of the sending and receiving buffers for this socket in
bytes. Most operating systems impose an upper limit on the size of
these buffers.
.. Availability: Linux, Windows
.. data::
SO_RCVLOWAT
SO_SNDLOWAT
``SO_RCVLOWAT`` sets the minimum number of bytes that must be present in
the socket's internal receive buffer before they are returned by a
read call. ``SO_SNDLOWAT`` similiary sets the minimum bytes before data is
sent from the send buffer to the socket protocol.
SO_SNDLOWAT is read-only on Linux and SO_RCVLOWAT is read-only on
Linux versions below 2.4.
.. Availability: Linux, Windows `(non functional) <https://msdn.microsoft.com/en-us/library/windows/desktop/ms740532(v=vs.85).aspx>`_
.. data:: SO_RCVTIMEO
SO_SNDTIMEO
Specifies the amount of time send and receive calls for this socket will
block before timing out. The default timeout of zero means that operations
will never time out.
This is independent of :meth:`~socket.settimeout`.
On Linux this is a `struct timeval`, on Windows this is an integer.
.. Availability: Linux, Windows
.. data:: SO_ERROR
Gets and resets the pending socket error.
.. Availability: Linux, Windows
.. data:: SO_TYPE
Gets the type of the socket. This type corresponds to the type as
defined in the :func:`socket.socket` function. Examples include
:const:`SOCK_STREAM` and :const:`SOCK_DGRAM`.
.. Availability: Linux, Windows
.. data:: SO_SETFIB
Sets the FIB (routing table) for the socket.
Availability: FreeBSD >= 7.1
.. versionadded:: 3.1
.. data:: SO_PASSCRED
SO_PEERCRED
Allows for the passing of SCM credentials over unix sockets. These
are passed as ancillary messages which can be received using :func:`~socket.recvmsg`
.. versionadded:: 3.3
.. Availability: Linux
.. data:: SO_PASSSEC
SO_PEERSEC
Allows for the passing of security contexts over unix sockets.
.. versionadded:: 3.6
.. Availability: Linux >= 2.6.2
.. data:: SO_BINDTODEVICE
Binds a socket to a particular network interface device like "eth0",
When bound, only packets received from that particular device are
processsed by the socket.
.. versionadded:: 3.3
.. Availability: Linux
.. data:: SO_PRIORITY
Sets the protocol-defined priority for each packet sent on this socket.
Packets with higher priority may be processed first depending on the
queueing mechanism of the network interface.
.. versionadded:: 3.4
.. Availability: Linux
.. data:: SO_MARK
Sets the mark on each packet sent through this socket. This may be used
for routing or packet filtering.
.. versionadded:: 3.5
.. Availability: Linux >= 2.6.25
.. data:: SO_DOMAIN
SO_PROTOCOL
Passing ``SO_DOMAIN`` to :meth:`~socket.getsockopt` allows for the retrival
of the ``family`` value as defined in the :func:`socket.socket` function.
``SO_PROTOCOL`` returns the ``proto`` value. The protocol value can be the
exact protocol used such as ``IPPROTO_TCP`` even if 0 was passed in to specify
the default protocol.
Both these options are read only.
The value returned for the ``family`` is an integer which is the value of
the constants above like :const:`AF_INET`. In order to get the const name
value back you can use the AddressFamily enum. ::
>>> family = s.getsockopt(socket.SOL_SOCKET, socket.SO_DOMAIN)
>>> socket.AddressFamily(family)
<AddressFamily.AF_INET: 2>
Availability: Linux >= 2.6.32.
.. versionadded:: 3.6
.. data:: SO_*
SOMAXCONN
MSG_*
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gh-45048: Document the availability and uses of the SO_ constants #132752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
gh-45048: Document the availability and uses of the SO_ constants #132752
Changes from 1 commit
2efa2c7
196aa97
0bf7f85
94b9881
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.