summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/fcntlmodule.c2
-rw-r--r--Modules/socketmodule.c43
-rw-r--r--Modules/socketmodule.h1
3 files changed, 44 insertions, 2 deletions
diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c
index 4361bfa..1539f21 100644
--- a/Modules/fcntlmodule.c
+++ b/Modules/fcntlmodule.c
@@ -378,7 +378,7 @@ following values:\n\
LOCK_SH - acquire a shared lock\n\
LOCK_EX - acquire an exclusive lock\n\
\n\
-When operation is LOCK_SH or LOCK_EX, it can also be bit-wise OR'd with\n\
+When operation is LOCK_SH or LOCK_EX, it can also be bitwise ORed with\n\
LOCK_NB to avoid blocking on lock acquisition. If LOCK_NB is used and the\n\
lock cannot be acquired, an IOError will be raised and the exception will\n\
have an errno attribute set to EACCES or EAGAIN (depending on the operating\n\
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 3909cbc..b59c15d 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -2510,6 +2510,31 @@ PyDoc_STRVAR(shutdown_doc,
Shut down the reading side of the socket (flag == SHUT_RD), the writing side\n\
of the socket (flag == SHUT_WR), or both ends (flag == SHUT_RDWR).");
+#ifdef MS_WINDOWS
+static PyObject*
+sock_ioctl(PySocketSockObject *s, PyObject *arg)
+{
+ unsigned long cmd = SIO_RCVALL;
+ unsigned int option = RCVALL_ON;
+ DWORD recv;
+
+ 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);
+}
+PyDoc_STRVAR(sock_ioctl_doc,
+"ioctl(cmd, option) -> long\n\
+\n\
+Control the socket with WSAIoctl syscall. Currently only socket.SIO_RCVALL\n\
+is supported as control. Options must be one of the socket.RCVALL_*\n\
+constants.");
+
+#endif
/* List of methods for socket objects */
@@ -2534,6 +2559,10 @@ static PyMethodDef sock_methods[] = {
METH_NOARGS, getsockname_doc},
{"getsockopt", (PyCFunction)sock_getsockopt, METH_VARARGS,
getsockopt_doc},
+#ifdef MS_WINDOWS
+ {"ioctl", (PyCFunction)sock_ioctl, METH_VARARGS,
+ sock_ioctl_doc},
+#endif
{"listen", (PyCFunction)sock_listen, METH_O,
listen_doc},
{"recv", (PyCFunction)sock_recv, METH_VARARGS,
@@ -3957,7 +3986,7 @@ See the socket module for documentation.");
PyMODINIT_FUNC
init_socket(void)
{
- PyObject *m, *has_ipv6;
+ PyObject *m, *has_ipv6, *tmp;
if (!os_init())
return;
@@ -4794,6 +4823,18 @@ init_socket(void)
PyModule_AddIntConstant(m, "SHUT_RDWR", 2);
#endif
+#ifdef SIO_RCVALL
+ tmp = PyLong_FromUnsignedLong(SIO_RCVALL);
+ if (tmp == NULL)
+ return;
+ PyModule_AddObject(m, "SIO_RCVALL", tmp);
+ PyModule_AddIntConstant(m, "RCVALL_OFF", RCVALL_OFF);
+ PyModule_AddIntConstant(m, "RCVALL_ON", RCVALL_ON);
+ PyModule_AddIntConstant(m, "RCVALL_SOCKETLEVELONLY", RCVALL_SOCKETLEVELONLY);
+ PyModule_AddIntConstant(m, "RCVALL_IPLEVEL", RCVALL_IPLEVEL);
+ PyModule_AddIntConstant(m, "RCVALL_MAX", RCVALL_MAX);
+#endif /* _MSTCPIP_ */
+
/* Initialize gethostbyname lock */
#if defined(USE_GETHOSTBYNAME_LOCK) || defined(USE_GETADDRINFO_LOCK)
netdb_lock = PyThread_allocate_lock();
diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h
index 1df1ae6..43c95fd 100644
--- a/Modules/socketmodule.h
+++ b/Modules/socketmodule.h
@@ -16,6 +16,7 @@
#if _MSC_VER >= 1300
# include <winsock2.h>
# include <ws2tcpip.h>
+# include <MSTcpIP.h> /* for SIO_RCVALL */
# define HAVE_ADDRINFO
# define HAVE_SOCKADDR_STORAGE
# define HAVE_GETADDRINFO