cpython: c64216addd7f (original) (raw)

--- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -198,6 +198,7 @@ The module :mod:socket exports the fol SOMAXCONN MSG_* SOL_*

@@ -511,6 +512,49 @@ The module :mod:socket exports the fol Availability: Unix (maybe not all platforms). +..

+.. function:: CMSG_LEN(length) +

+ +.. function:: CMSG_SPACE(length) +

+ .. function:: getdefaulttimeout() Return the default timeout in seconds (float) for new socket objects. A value @@ -742,6 +786,109 @@ correspond to Unix system calls applicab to zero. (The format of address depends on the address family --- see above.) +.. method:: socket.recvmsg(bufsize[, ancbufsize[, flags]]) +

+

+

+ +.. method:: socket.recvmsg_into(buffers[, ancbufsize[, flags]]) +

+

+ .. method:: socket.recvfrom_into(buffer[, nbytes[, flags]]) Receive data from the socket, writing it into buffer instead of creating a @@ -789,6 +936,41 @@ correspond to Unix system calls applicab above.) +.. method:: socket.sendmsg(buffers[, ancdata[, flags[, address]]]) +

+

+

+ .. method:: socket.setblocking(flag) Set blocking or non-blocking mode of the socket: if flag is false, the

--- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -212,6 +212,18 @@ signal

--- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -355,6 +355,14 @@ class SSLSocket(socket): else: return socket.sendto(self, data, flags_or_addr, addr)

+ def sendall(self, data, flags=0): self._checkClosed() if self._sslobj: @@ -413,6 +421,22 @@ class SSLSocket(socket): else: return socket.recvfrom_into(self, buffer, nbytes, flags)

+

+ def pending(self): self._checkClosed() if self._sslobj:

--- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -7,6 +7,8 @@ import errno import io import socket import select +import tempfile +import _testcapi import time import traceback import queue @@ -34,6 +36,9 @@ except ImportError: thread = None threading = None +# Size in bytes of the int type +SIZEOF_INT = array.array("i").itemsize + class SocketTCPTest(unittest.TestCase): def setUp(self): @@ -55,6 +60,26 @@ class SocketUDPTest(unittest.TestCase): self.serv.close() self.serv = None +class ThreadSafeCleanupTestCase(unittest.TestCase):

+

+

+

+

+ class ThreadableTest: """Threadable Test class @@ -237,6 +262,243 @@ class SocketPairTest(unittest.TestCase, ThreadableTest.clientTearDown(self) +# The following classes are used by the sendmsg()/recvmsg() tests. +# Combining, for instance, ConnectedStreamTestMixin and TCPTestBase +# gives a drop-in replacement for SocketConnectedTest, but different +# address families can be used, and the attributes serv_addr and +# cli_addr will be set to the addresses of the endpoints. + +class SocketTestBase(unittest.TestCase):

+

+

+

+

+

+ + +class SocketListeningTestMixin(SocketTestBase):

+

+ + +class ThreadedSocketTestMixin(ThreadSafeCleanupTestCase, SocketTestBase,

+

+

+

+

+

+

+ + +class ConnectedStreamTestMixin(SocketListeningTestMixin,

+

+

+

+

+

+ + +class UnixSocketTestBase(SocketTestBase):

+

+

+

+ +class UnixStreamBase(UnixSocketTestBase):

+

+ + +class InetTestBase(SocketTestBase):

+

+

+

+ +class TCPTestBase(InetTestBase):

+

+ +class UDPTestBase(InetTestBase):

+

+ +class SCTPStreamBase(InetTestBase):

+

+ + +class Inet6TestBase(InetTestBase):

+

+ +class UDP6TestBase(Inet6TestBase):

+

+ + +# Test-skipping decorators for use with ThreadableTest. + +def skipWithClientIf(condition, reason):

+

+ + +def requireAttrs(obj, *attributes):

+

+ + +def requireSocket(*args):

+

+ + #######################################################################

Begin Tests

@@ -945,6 +1207,1839 @@ class BasicUDPTest(ThreadedUDPSocketTest def _testRecvFromNegative(self): self.cli.sendto(MSG, 0, (HOST, self.port)) + +# Tests for the sendmsg()/recvmsg() interface. Where possible, the +# same test code is used with different families and types of socket +# (e.g. stream, datagram), and tests using recvmsg() are repeated +# using recvmsg_into(). +# +# The generic test classes such as SendmsgTests and +# RecvmsgGenericTests inherit from SendrecvmsgBase and expect to be +# supplied with sockets cli_sock and serv_sock representing the +# client's and the server's end of the connection respectively, and +# attributes cli_addr and serv_addr holding their (numeric where +# appropriate) addresses. +# +# The final concrete test classes combine these with subclasses of +# SocketTestBase which set up client and server sockets of a specific +# type, and with subclasses of SendrecvmsgBase such as +# SendrecvmsgDgramBase and SendrecvmsgConnectedBase which map these +# sockets to cli_sock and serv_sock and override the methods and +# attributes of SendrecvmsgBase to fill in destination addresses if +# needed when sending, check for specific flags in msg_flags, etc. +# +# RecvmsgIntoMixin provides a version of doRecvmsg() implemented using +# recvmsg_into(). + +# XXX: like the other datagram (UDP) tests in this module, the code +# here assumes that datagram delivery on the local machine will be +# reliable. + +class SendrecvmsgBase(ThreadSafeCleanupTestCase):

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ + +class RecvmsgIntoMixin(SendrecvmsgBase):

+

+ + +class SendrecvmsgDgramFlagsBase(SendrecvmsgBase):

+

+ + +class SendrecvmsgSCTPFlagsBase(SendrecvmsgBase):

+

+ + +class SendrecvmsgConnectionlessBase(SendrecvmsgBase):

+

+

+

+

+ + +class SendrecvmsgConnectedBase(SendrecvmsgBase):

+

+

+

+ + +class SendrecvmsgServerTimeoutBase(SendrecvmsgBase):

+

+ + +class SendmsgTests(SendrecvmsgServerTimeoutBase):

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ + +class SendmsgStreamTests(SendmsgTests):

+

+

+

+

+

+

+

+ + +class SendmsgConnectionlessTests(SendmsgTests):

+

+

+ + +class RecvmsgGenericTests(SendrecvmsgBase):

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ + +class RecvmsgGenericStreamTests(RecvmsgGenericTests):

+

+

+

+

+

+

+ + +class RecvmsgTests(RecvmsgGenericTests):

+

+

+

+ + +class RecvmsgIntoTests(RecvmsgIntoMixin, RecvmsgGenericTests):

+

+

+

+

+

+

+

+

+

+ + +class CmsgMacroTests(unittest.TestCase):

+

+

+

+

+

+

+

+ + +class SCMRightsTest(SendrecvmsgServerTimeoutBase):

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ + +class RFC3542AncillaryTest(SendrecvmsgServerTimeoutBase):

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+ + +# Derive concrete test classes for different socket types. + +class SendrecvmsgUDPTestBase(SendrecvmsgDgramFlagsBase,

+ +@requireAttrs(socket.socket, "sendmsg") +@unittest.skipUnless(thread, 'Threading required for this test.') +class SendmsgUDPTest(SendmsgConnectionlessTests, SendrecvmsgUDPTestBase):

+ +@requireAttrs(socket.socket, "recvmsg") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgUDPTest(RecvmsgTests, SendrecvmsgUDPTestBase):

+ +@requireAttrs(socket.socket, "recvmsg_into") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgIntoUDPTest(RecvmsgIntoTests, SendrecvmsgUDPTestBase):

+ + +class SendrecvmsgUDP6TestBase(SendrecvmsgDgramFlagsBase,

+ +@requireAttrs(socket.socket, "sendmsg") +@unittest.skipUnless(socket.has_ipv6, "Python not built with IPv6 support") +@requireSocket("AF_INET6", "SOCK_DGRAM") +@unittest.skipUnless(thread, 'Threading required for this test.') +class SendmsgUDP6Test(SendmsgConnectionlessTests, SendrecvmsgUDP6TestBase):

+ +@requireAttrs(socket.socket, "recvmsg") +@unittest.skipUnless(socket.has_ipv6, "Python not built with IPv6 support") +@requireSocket("AF_INET6", "SOCK_DGRAM") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgUDP6Test(RecvmsgTests, SendrecvmsgUDP6TestBase):

+ +@requireAttrs(socket.socket, "recvmsg_into") +@unittest.skipUnless(socket.has_ipv6, "Python not built with IPv6 support") +@requireSocket("AF_INET6", "SOCK_DGRAM") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgIntoUDP6Test(RecvmsgIntoTests, SendrecvmsgUDP6TestBase):

+ +@requireAttrs(socket.socket, "recvmsg") +@unittest.skipUnless(socket.has_ipv6, "Python not built with IPv6 support") +@requireAttrs(socket, "IPPROTO_IPV6") +@requireSocket("AF_INET6", "SOCK_DGRAM") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgRFC3542AncillaryUDP6Test(RFC3542AncillaryTest,

+ +@requireAttrs(socket.socket, "recvmsg_into") +@unittest.skipUnless(socket.has_ipv6, "Python not built with IPv6 support") +@requireAttrs(socket, "IPPROTO_IPV6") +@requireSocket("AF_INET6", "SOCK_DGRAM") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgIntoRFC3542AncillaryUDP6Test(RecvmsgIntoMixin,

+ + +class SendrecvmsgTCPTestBase(SendrecvmsgConnectedBase,

+ +@requireAttrs(socket.socket, "sendmsg") +@unittest.skipUnless(thread, 'Threading required for this test.') +class SendmsgTCPTest(SendmsgStreamTests, SendrecvmsgTCPTestBase):

+ +@requireAttrs(socket.socket, "recvmsg") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgTCPTest(RecvmsgTests, RecvmsgGenericStreamTests,

+ +@requireAttrs(socket.socket, "recvmsg_into") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgIntoTCPTest(RecvmsgIntoTests, RecvmsgGenericStreamTests,

+ + +class SendrecvmsgSCTPStreamTestBase(SendrecvmsgSCTPFlagsBase,

+ +@requireAttrs(socket.socket, "sendmsg") +@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") +@unittest.skipUnless(thread, 'Threading required for this test.') +class SendmsgSCTPStreamTest(SendmsgStreamTests, SendrecvmsgSCTPStreamTestBase):

+ +@requireAttrs(socket.socket, "recvmsg") +@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgSCTPStreamTest(RecvmsgTests, RecvmsgGenericStreamTests,

+ +@requireAttrs(socket.socket, "recvmsg_into") +@requireSocket("AF_INET", "SOCK_STREAM", "IPPROTO_SCTP") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgIntoSCTPStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests,

+ + +class SendrecvmsgUnixStreamTestBase(SendrecvmsgConnectedBase,

+ +@requireAttrs(socket.socket, "sendmsg") +@requireAttrs(socket, "AF_UNIX") +@unittest.skipUnless(thread, 'Threading required for this test.') +class SendmsgUnixStreamTest(SendmsgStreamTests, SendrecvmsgUnixStreamTestBase):

+ +@requireAttrs(socket.socket, "recvmsg") +@requireAttrs(socket, "AF_UNIX") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgUnixStreamTest(RecvmsgTests, RecvmsgGenericStreamTests,

+ +@requireAttrs(socket.socket, "recvmsg_into") +@requireAttrs(socket, "AF_UNIX") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgIntoUnixStreamTest(RecvmsgIntoTests, RecvmsgGenericStreamTests,

+ +@requireAttrs(socket.socket, "sendmsg", "recvmsg") +@requireAttrs(socket, "AF_UNIX", "SOL_SOCKET", "SCM_RIGHTS") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgSCMRightsStreamTest(SCMRightsTest, SendrecvmsgUnixStreamTestBase):

+ +@requireAttrs(socket.socket, "sendmsg", "recvmsg_into") +@requireAttrs(socket, "AF_UNIX", "SOL_SOCKET", "SCM_RIGHTS") +@unittest.skipUnless(thread, 'Threading required for this test.') +class RecvmsgIntoSCMRightsStreamTest(RecvmsgIntoMixin, SCMRightsTest,

+ + +# Test interrupting the interruptible send/receive methods with a +# signal when a timeout is set. These tests avoid having multiple +# threads alive during the test so that the OS cannot deliver the +# signal to the wrong one. + +class InterruptedTimeoutBase(unittest.TestCase):

+

+

+

+

+

+ + +# Require siginterrupt() in order to ensure that system calls are +# interrupted by default. +@requireAttrs(signal, "siginterrupt") +@unittest.skipUnless(hasattr(signal, "alarm") or hasattr(signal, "setitimer"),

+class InterruptedRecvTimeoutTest(InterruptedTimeoutBase, UDPTestBase):

+

+

+

+

+

+

+

+

+ + +# Require siginterrupt() in order to ensure that system calls are +# interrupted by default. +@requireAttrs(signal, "siginterrupt") +@unittest.skipUnless(hasattr(signal, "alarm") or hasattr(signal, "setitimer"),

+@unittest.skipUnless(thread, 'Threading required for this test.') +class InterruptedSendTimeoutTest(InterruptedTimeoutBase,

+

+

+

+

+

+

+ + @unittest.skipUnless(thread, 'Threading required for this test.') class TCPCloserTest(ThreadedTCPSocketTest): @@ -2077,6 +4172,31 @@ def test_main(): if isTipcAvailable(): tests.append(TIPCTest) tests.append(TIPCThreadableTest)

thread_info = support.threading_setup() support.run_unittest(*tests)

--- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -186,8 +186,11 @@ class BasicSocketTests(unittest.TestCase self.assertRaises(socket.error, ss.recv_into, bytearray(b'x')) self.assertRaises(socket.error, ss.recvfrom, 1) self.assertRaises(socket.error, ss.recvfrom_into, bytearray(b'x'), 1)

def test_timeout(self): # Issue #8524: when creating an SSL socket, the timeout of the @@ -1520,17 +1523,30 @@ else: count, addr = s.recvfrom_into(b) return b[:count]

+

+

+ # (name, method, whether to expect success, *args) send_methods = [ ('send', s.send, True, []), ('sendto', s.sendto, False, ["some.address"]),

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -265,6 +265,10 @@ Core and Builtins Library ------- +- Issue #6560: The sendmsg/recvmsg API is now exposed by the socket module

--- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -263,6 +263,7 @@ if_indextoname(index) -- return the corr #ifdef HAVE_NET_IF_H #include <net/if.h> #endif +#include <unistd.h> /* Generic socket object definitions and includes / #define PySocket_BUILDING_SOCKET @@ -469,6 +470,17 @@ static PyTypeObject sock_type; #include <sys/poll.h> #endif +/ Largest value to try to store in a socklen_t (used when handling

#ifdef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE /* Platform can select file descriptors beyond FD_SETSIZE */ #define IS_SELECTABLE(s) 1 @@ -1678,6 +1690,117 @@ getsockaddrlen(PySocketSockObject s, so } +/ Support functions for the sendmsg() and recvmsg_into methods.

+

+} + +#ifdef CMSG_SPACE +/* If length is in range, set *result to CMSG_SPACE(length) and return

+

+} +#endif + +/* Return true iff msg->msg_controllen is valid, cmsgh is a valid

+

+} + +/* If pointer CMSG_DATA(cmsgh) is in buffer msg->msg_control, set

+

+} + +/* If cmsgh is invalid or not contained in the buffer pointed to by

+

+} +#endif /* CMSG_LEN / + + / s._accept() -> (fd, address) */ static PyObject @@ -2631,6 +2754,333 @@ PyDoc_STRVAR(recvfrom_into_doc, Like recv_into(buffer[, nbytes[, flags]]) but also return the sender's address info."); +/ The sendmsg() and recvmsg_into methods require a working

+{

+

+

+

+

+

+

+

+

+

+

+ +finally:

+ +err_closefds: +#ifdef SCM_RIGHTS

+

+#endif /* SCM_RIGHTS */

+} + + +static PyObject * +makeval_recvmsg(ssize_t received, void *data) +{

+

+} + +/* s.recvmsg(bufsize[, ancbufsize[, flags]]) method */ + +static PyObject * +sock_recvmsg(PySocketSockObject *s, PyObject *args) +{

+

+

+

+} + +PyDoc_STRVAR(recvmsg_doc, +"recvmsg(bufsize[, ancbufsize[, flags]]) -> (data, ancdata, msg_flags, address)\n[](#l7.354) +\n[](#l7.355) +Receive normal data (up to bufsize bytes) and ancillary data from the\n[](#l7.356) +socket. The ancbufsize argument sets the size in bytes of the\n[](#l7.357) +internal buffer used to receive the ancillary data; it defaults to 0,\n[](#l7.358) +meaning that no ancillary data will be received. Appropriate buffer\n[](#l7.359) +sizes for ancillary data can be calculated using CMSG_SPACE() or\n[](#l7.360) +CMSG_LEN(), and items which do not fit into the buffer might be\n[](#l7.361) +truncated or discarded. The flags argument defaults to 0 and has the\n[](#l7.362) +same meaning as for recv().\n[](#l7.363) +\n[](#l7.364) +The return value is a 4-tuple: (data, ancdata, msg_flags, address).\n[](#l7.365) +The data item is a bytes object holding the non-ancillary data\n[](#l7.366) +received. The ancdata item is a list of zero or more tuples\n[](#l7.367) +(cmsg_level, cmsg_type, cmsg_data) representing the ancillary data\n[](#l7.368) +(control messages) received: cmsg_level and cmsg_type are integers\n[](#l7.369) +specifying the protocol level and protocol-specific type respectively,\n[](#l7.370) +and cmsg_data is a bytes object holding the associated data. The\n[](#l7.371) +msg_flags item is the bitwise OR of various flags indicating\n[](#l7.372) +conditions on the received message; see your system documentation for\n[](#l7.373) +details. If the receiving socket is unconnected, address is the\n[](#l7.374) +address of the sending socket, if available; otherwise, its value is\n[](#l7.375) +unspecified.\n[](#l7.376) +\n[](#l7.377) +If recvmsg() raises an exception after the system call returns, it\n[](#l7.378) +will first attempt to close any file descriptors received via the\n[](#l7.379) +SCM_RIGHTS mechanism."); + + +static PyObject * +makeval_recvmsg_into(ssize_t received, void *data) +{

+} + +/* s.recvmsg_into(buffers[, ancbufsize[, flags]]) method */ + +static PyObject * +sock_recvmsg_into(PySocketSockObject *s, PyObject *args) +{

+

+

+

+

+finally:

+} + +PyDoc_STRVAR(recvmsg_into_doc, +"recvmsg_into(buffers[, ancbufsize[, flags]]) -> (nbytes, ancdata, msg_flags, address)\n[](#l7.444) +\n[](#l7.445) +Receive normal data and ancillary data from the socket, scattering the\n[](#l7.446) +non-ancillary data into a series of buffers. The buffers argument\n[](#l7.447) +must be an iterable of objects that export writable buffers\n[](#l7.448) +(e.g. bytearray objects); these will be filled with successive chunks\n[](#l7.449) +of the non-ancillary data until it has all been written or there are\n[](#l7.450) +no more buffers. The ancbufsize argument sets the size in bytes of\n[](#l7.451) +the internal buffer used to receive the ancillary data; it defaults to\n[](#l7.452) +0, meaning that no ancillary data will be received. Appropriate\n[](#l7.453) +buffer sizes for ancillary data can be calculated using CMSG_SPACE()\n[](#l7.454) +or CMSG_LEN(), and items which do not fit into the buffer might be\n[](#l7.455) +truncated or discarded. The flags argument defaults to 0 and has the\n[](#l7.456) +same meaning as for recv().\n[](#l7.457) +\n[](#l7.458) +The return value is a 4-tuple: (nbytes, ancdata, msg_flags, address).\n[](#l7.459) +The nbytes item is the total number of bytes of non-ancillary data\n[](#l7.460) +written into the buffers. The ancdata item is a list of zero or more\n[](#l7.461) +tuples (cmsg_level, cmsg_type, cmsg_data) representing the ancillary\n[](#l7.462) +data (control messages) received: cmsg_level and cmsg_type are\n[](#l7.463) +integers specifying the protocol level and protocol-specific type\n[](#l7.464) +respectively, and cmsg_data is a bytes object holding the associated\n[](#l7.465) +data. The msg_flags item is the bitwise OR of various flags\n[](#l7.466) +indicating conditions on the received message; see your system\n[](#l7.467) +documentation for details. If the receiving socket is unconnected,\n[](#l7.468) +address is the address of the sending socket, if available; otherwise,\n[](#l7.469) +its value is unspecified.\n[](#l7.470) +\n[](#l7.471) +If recvmsg_into() raises an exception after the system call returns,\n[](#l7.472) +it will first attempt to close any file descriptors received via the\n[](#l7.473) +SCM_RIGHTS mechanism."); +#endif /* CMSG_LEN / + + / s.send(data [,flags]) method */ static PyObject @@ -2826,6 +3276,237 @@ Like send(data, flags) but allows specif For IP sockets, the address is a pair (hostaddr, port)."); +/ The sendmsg() and recvmsg_into methods require a working

+static PyObject * +sock_sendmsg(PySocketSockObject *s, PyObject *args) +{

+

+

+

+

+

+ +#ifndef CMSG_SPACE

+#endif

+

+ +#ifdef CMSG_SPACE

+#else

+#endif

+

+

+

+

+

+

+

+

+

+ +finally:

+} + +PyDoc_STRVAR(sendmsg_doc, +"sendmsg(buffers[, ancdata[, flags[, address]]]) -> count\n[](#l7.698) +\n[](#l7.699) +Send normal and ancillary data to the socket, gathering the\n[](#l7.700) +non-ancillary data from a series of buffers and concatenating it into\n[](#l7.701) +a single message. The buffers argument specifies the non-ancillary\n[](#l7.702) +data as an iterable of buffer-compatible objects (e.g. bytes objects).\n[](#l7.703) +The ancdata argument specifies the ancillary data (control messages)\n[](#l7.704) +as an iterable of zero or more tuples (cmsg_level, cmsg_type,\n[](#l7.705) +cmsg_data), where cmsg_level and cmsg_type are integers specifying the\n[](#l7.706) +protocol level and protocol-specific type respectively, and cmsg_data\n[](#l7.707) +is a buffer-compatible object holding the associated data. The flags\n[](#l7.708) +argument defaults to 0 and has the same meaning as for send(). If\n[](#l7.709) +address is supplied and not None, it sets a destination address for\n[](#l7.710) +the message. The return value is the number of bytes of non-ancillary\n[](#l7.711) +data sent."); +#endif /* CMSG_LEN / + + / s.shutdown(how) method */ static PyObject * @@ -2952,6 +3633,14 @@ static PyMethodDef sock_methods[] = { setsockopt_doc}, {"shutdown", (PyCFunction)sock_shutdown, METH_O, shutdown_doc}, +#ifdef CMSG_LEN

+#endif {NULL, NULL} /* sentinel / }; @@ -4377,6 +5066,68 @@ Returns the interface name corresponding #endif / HAVE_IF_NAMEINDEX / +#ifdef CMSG_LEN +/ Python interface to CMSG_LEN(length). */ + +static PyObject * +socket_CMSG_LEN(PyObject *self, PyObject *args) +{

+

+} + +PyDoc_STRVAR(CMSG_LEN_doc, +"CMSG_LEN(length) -> control message length\n[](#l7.757) +\n[](#l7.758) +Return the total length, without trailing padding, of an ancillary\n[](#l7.759) +data item with associated data of the given length. This value can\n[](#l7.760) +often be used as the buffer size for recvmsg() to receive a single\n[](#l7.761) +item of ancillary data, but RFC 3542 requires portable applications to\n[](#l7.762) +use CMSG_SPACE() and thus include space for padding, even when the\n[](#l7.763) +item will be the last in the buffer. Raises OverflowError if length\n[](#l7.764) +is outside the permissible range of values."); + + +#ifdef CMSG_SPACE +/* Python interface to CMSG_SPACE(length). */ + +static PyObject * +socket_CMSG_SPACE(PyObject *self, PyObject *args) +{

+

+} + +PyDoc_STRVAR(CMSG_SPACE_doc, +"CMSG_SPACE(length) -> buffer size\n[](#l7.788) +\n[](#l7.789) +Return the buffer size needed for recvmsg() to receive an ancillary\n[](#l7.790) +data item with associated data of the given length, along with any\n[](#l7.791) +trailing padding. The buffer space needed to receive multiple items\n[](#l7.792) +is the sum of the CMSG_SPACE() values for their associated data\n[](#l7.793) +lengths. Raises OverflowError if length is outside the permissible\n[](#l7.794) +range of values."); +#endif /* CMSG_SPACE / +#endif / CMSG_LEN / + + / List of functions exported by this module. */ static PyMethodDef socket_methods[] = { @@ -4440,6 +5191,14 @@ static PyMethodDef socket_methods[] = { {"if_indextoname", socket_if_indextoname, METH_O, if_indextoname_doc}, #endif +#ifdef CMSG_LEN

+#ifdef CMSG_SPACE

+#endif +#endif {NULL, NULL} /* Sentinel */ }; @@ -4927,6 +5686,15 @@ PyInit__socket(void) #ifdef SO_SETFIB PyModule_AddIntConstant(m, "SO_SETFIB", SO_SETFIB); #endif +#ifdef SO_PASSCRED

+#endif +#ifdef SO_PEERCRED

+#endif +#ifdef LOCAL_PEERCRED

+#endif /* Maximum number of connections for "listen" / #ifdef SOMAXCONN @@ -4935,6 +5703,17 @@ PyInit__socket(void) PyModule_AddIntConstant(m, "SOMAXCONN", 5); / Common value */ #endif

+#ifdef SCM_RIGHTS

+#endif +#ifdef SCM_CREDENTIALS

+#endif +#ifdef SCM_CREDS

+#endif + /* Flags for send, recv */ #ifdef MSG_OOB PyModule_AddIntConstant(m, "MSG_OOB", MSG_OOB); @@ -4966,6 +5745,33 @@ PyInit__socket(void) #ifdef MSG_ETAG PyModule_AddIntConstant(m, "MSG_ETAG", MSG_ETAG); #endif +#ifdef MSG_NOSIGNAL

+#endif +#ifdef MSG_NOTIFICATION

+#endif +#ifdef MSG_CMSG_CLOEXEC

+#endif +#ifdef MSG_ERRQUEUE

+#endif +#ifdef MSG_CONFIRM

+#endif +#ifdef MSG_MORE

+#endif +#ifdef MSG_EOF

+#endif +#ifdef MSG_BCAST

+#endif +#ifdef MSG_MCAST

+#endif /* Protocol level and numbers, usable for [gs]etsockopt */ #ifdef SOL_SOCKET @@ -5105,6 +5911,9 @@ PyInit__socket(void) #ifdef IPPROTO_VRRP PyModule_AddIntConstant(m, "IPPROTO_VRRP", IPPROTO_VRRP); #endif +#ifdef IPPROTO_SCTP

+#endif #ifdef IPPROTO_BIP PyModule_AddIntConstant(m, "IPPROTO_BIP", IPPROTO_BIP); #endif