diff -r 3c75707045f5 Doc/library/socket.rst --- a/Doc/library/socket.rst Wed May 11 11:53:01 2016 +1000 +++ b/Doc/library/socket.rst Thu May 19 18:51:46 2016 -0700 @@ -326,12 +326,17 @@ .. versionadded:: 3.3 -.. data:: SIO_* +.. data:: SIO_RCVALL + SIO_KEEPALIVE_VALS + SIO_LOOPBACK_FAST_PATH RCVALL_* Constants for Windows' WSAIoctl(). The constants are used as arguments to the :meth:`~socket.socket.ioctl` method of socket objects. + .. versionchanged:: 3.6 + ``SIO_LOOPBACK_FAST_PATH`` was added. + .. data:: TIPC_* @@ -994,6 +999,12 @@ On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl` functions may be used; they accept a socket object as their first argument. + Currently only the following control codes are supported: + ``SIO_RCVALL``, ``SIO_KEEPALIVE_VALS``, and ``SIO_LOOPBACK_FAST_PATH``. + + .. versionchanged:: 3.6 + ``SIO_LOOPBACK_FAST_PATH`` was added. + .. method:: socket.listen([backlog]) Enable a server to accept connections. If *backlog* is specified, it must diff -r 3c75707045f5 Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst Wed May 11 11:53:01 2016 +1000 +++ b/Doc/whatsnew/3.6.rst Thu May 19 18:51:46 2016 -0700 @@ -259,6 +259,14 @@ (Contributed by Wolfgang Langner in :issue:`26587`). +socket +------ + +The :func:`~socket.socket.ioctl` function now supports the :data:`~socket.SIO_LOOPBACK_FAST_PATH` +control code. +(Contributed by Daniel Stokes in :issue:`26536`.) + + socketserver ------------ diff -r 3c75707045f5 Lib/test/test_socket.py --- a/Lib/test/test_socket.py Wed May 11 11:53:01 2016 +1000 +++ b/Lib/test/test_socket.py Thu May 19 18:51:46 2016 -0700 @@ -1217,6 +1217,16 @@ self.assertRaises(ValueError, s.ioctl, -1, None) s.ioctl(socket.SIO_KEEPALIVE_VALS, (1, 100, 100)) + @unittest.skipUnless(os.name == "nt", "Windows specific") + @unittest.skipUnless(hasattr(socket, 'SIO_LOOPBACK_FAST_PATH'), + 'Loopback fast path support required for this test') + def test_sio_loopback_fast_path(self): + s = socket.socket() + self.addCleanup(s.close) + s.ioctl(socket.SIO_LOOPBACK_FAST_PATH, True) + self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None) + + def testGetaddrinfo(self): try: socket.getaddrinfo('localhost', 80) diff -r 3c75707045f5 Misc/ACKS --- a/Misc/ACKS Wed May 11 11:53:01 2016 +1000 +++ b/Misc/ACKS Thu May 19 18:51:46 2016 -0700 @@ -1415,6 +1415,7 @@ Richard Stoakley Peter Stoehr Casper Stoel +Daniel Stokes Michael Stone Serhiy Storchaka Ken Stox diff -r 3c75707045f5 Modules/socketmodule.c --- a/Modules/socketmodule.c Wed May 11 11:53:01 2016 +1000 +++ b/Modules/socketmodule.c Thu May 19 18:51:46 2016 -0700 @@ -4049,6 +4049,17 @@ return set_error(); } return PyLong_FromUnsignedLong(recv); } +#if defined(SIO_LOOPBACK_FAST_PATH) + case SIO_LOOPBACK_FAST_PATH: { + unsigned int option; + if (!PyArg_ParseTuple(arg, "kI:ioctl", &cmd, &option)) + return NULL; + if (WSAIoctl(s->sock_fd, cmd, &option, sizeof(option), + NULL, 0, &recv, NULL, NULL) == SOCKET_ERROR) { + return set_error(); + } + return PyLong_FromUnsignedLong(recv); } +#endif default: PyErr_Format(PyExc_ValueError, "invalid ioctl command %d", cmd); return NULL; @@ -4059,7 +4070,8 @@ \n\ Control the socket with WSAIoctl syscall. Currently supported 'cmd' values are\n\ SIO_RCVALL: 'option' must be one of the socket.RCVALL_* constants.\n\ -SIO_KEEPALIVE_VALS: 'option' is a tuple of (onoff, timeout, interval)."); +SIO_KEEPALIVE_VALS: 'option' is a tuple of (onoff, timeout, interval).\n\ +SIO_LOOPBACK_FAST_PATH: 'option' is a boolean value, and is disabled by default"); #endif #if defined(MS_WINDOWS) @@ -7268,8 +7280,16 @@ #ifdef SIO_RCVALL { - DWORD codes[] = {SIO_RCVALL, SIO_KEEPALIVE_VALS}; - const char *names[] = {"SIO_RCVALL", "SIO_KEEPALIVE_VALS"}; + DWORD codes[] = {SIO_RCVALL, SIO_KEEPALIVE_VALS, +#if defined(SIO_LOOPBACK_FAST_PATH) + SIO_LOOPBACK_FAST_PATH +#endif + }; + const char *names[] = {"SIO_RCVALL", "SIO_KEEPALIVE_VALS", +#if defined(SIO_LOOPBACK_FAST_PATH) + "SIO_LOOPBACK_FAST_PATH" +#endif + }; int i; for(i = 0; i