Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
54ee5c90
Commit
54ee5c90
authored
Jan 04, 2008
by
Christian Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added interface to Windows' WSAIoctl and a simple example for a network sniffer.
parent
f35c3d5b
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
953 additions
and
865 deletions
+953
-865
Doc/library/socket.rst
Doc/library/socket.rst
+906
-863
Lib/socket.py
Lib/socket.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
Modules/socketmodule.c
Modules/socketmodule.c
+42
-1
Modules/socketmodule.h
Modules/socketmodule.h
+1
-0
No files found.
Doc/library/socket.rst
View file @
54ee5c90
This diff is collapsed.
Click to expand it.
Lib/socket.py
View file @
54ee5c90
...
...
@@ -141,7 +141,7 @@ _socketmethods = (
'bind'
,
'connect'
,
'connect_ex'
,
'fileno'
,
'listen'
,
'getpeername'
,
'getsockname'
,
'getsockopt'
,
'setsockopt'
,
'sendall'
,
'setblocking'
,
'settimeout'
,
'gettimeout'
,
'shutdown'
)
'settimeout'
,
'gettimeout'
,
'shutdown'
,
'ioctl'
)
if
sys
.
platform
==
"riscos"
:
_socketmethods
=
_socketmethods
+
(
'sleeptaskw'
,)
...
...
Misc/NEWS
View file @
54ee5c90
...
...
@@ -920,6 +920,9 @@ Library
Extension
Modules
-----------------
-
Added
interface
for
Windows
' WSAIoctl to socket object and added an example
for a simple network sniffer.
- Bug #1301: Bad assert in _tkinter fixed.
- Added bdist_wininst executable for VS 2008.
...
...
Modules/socketmodule.c
View file @
54ee5c90
...
...
@@ -2687,6 +2687,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 */
...
...
@@ -2715,6 +2740,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
},
#ifndef NO_DUP
...
...
@@ -4194,7 +4223,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
;
...
...
@@ -5033,6 +5062,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
();
...
...
Modules/socketmodule.h
View file @
54ee5c90
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment