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
be6bdf7b
Commit
be6bdf7b
authored
Sep 27, 2009
by
Kristján Valur Jónsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http://bugs.python.org/issue6971
Porting revision 75054 from trunk
parent
cf4e132d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
15 deletions
+43
-15
Lib/test/test_socket.py
Lib/test/test_socket.py
+4
-0
Modules/socketmodule.c
Modules/socketmodule.c
+39
-15
No files found.
Lib/test/test_socket.py
View file @
be6bdf7b
...
...
@@ -553,6 +553,10 @@ class GeneralModuleTests(unittest.TestCase):
self
.
assertTrue
(
hasattr
(
socket
,
'SIO_RCVALL'
))
self
.
assertTrue
(
hasattr
(
socket
,
'RCVALL_ON'
))
self
.
assertTrue
(
hasattr
(
socket
,
'RCVALL_OFF'
))
self
.
assertTrue
(
hasattr
(
socket
,
'SIO_KEEPALIVE_VALS'
))
s
=
socket
.
socket
()
self
.
assertRaises
(
ValueError
,
s
.
ioctl
,
-
1
,
None
)
s
.
ioctl
(
socket
.
SIO_KEEPALIVE_VALS
,
(
1
,
100
,
100
))
class
BasicTCPTest
(
SocketConnectedTest
):
...
...
Modules/socketmodule.c
View file @
be6bdf7b
...
...
@@ -2686,24 +2686,43 @@ static PyObject*
sock_ioctl
(
PySocketSockObject
*
s
,
PyObject
*
arg
)
{
unsigned
long
cmd
=
SIO_RCVALL
;
unsigned
int
option
=
RCVALL_ON
;
PyObject
*
argO
;
DWORD
recv
;
if
(
!
PyArg_ParseTuple
(
arg
,
"k
I:ioctl"
,
&
cmd
,
&
option
))
if
(
!
PyArg_ParseTuple
(
arg
,
"k
O:ioctl"
,
&
cmd
,
&
argO
))
return
NULL
;
switch
(
cmd
)
{
case
SIO_RCVALL
:
{
unsigned
int
option
=
RCVALL_ON
;
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
);
return
PyLong_FromUnsignedLong
(
recv
);
}
case
SIO_KEEPALIVE_VALS
:
{
struct
tcp_keepalive
ka
;
if
(
!
PyArg_ParseTuple
(
arg
,
"k(kkk):ioctl"
,
&
cmd
,
&
ka
.
onoff
,
&
ka
.
keepalivetime
,
&
ka
.
keepaliveinterval
))
return
NULL
;
if
(
WSAIoctl
(
s
->
sock_fd
,
cmd
,
&
ka
,
sizeof
(
ka
),
NULL
,
0
,
&
recv
,
NULL
,
NULL
)
==
SOCKET_ERROR
)
{
return
set_error
();
}
return
PyLong_FromUnsignedLong
(
recv
);
}
default:
PyErr_Format
(
PyExc_ValueError
,
"invalid ioctl command %d"
,
cmd
);
return
NULL
;
}
}
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
."
);
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)
."
);
#endif
...
...
@@ -5058,11 +5077,16 @@ PyInit__socket(void)
#ifdef SIO_RCVALL
{
DWORD
codes
[]
=
{
SIO_RCVALL
,
SIO_KEEPALIVE_VALS
};
const
char
*
names
[]
=
{
"SIO_RCVALL"
,
"SIO_KEEPALIVE_VALS"
};
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
codes
)
/
sizeof
(
*
codes
);
++
i
)
{
PyObject
*
tmp
;
tmp
=
PyLong_FromUnsignedLong
(
SIO_RCVALL
);
tmp
=
PyLong_FromUnsignedLong
(
codes
[
i
]
);
if
(
tmp
==
NULL
)
return
NULL
;
PyModule_AddObject
(
m
,
"SIO_RCVALL"
,
tmp
);
PyModule_AddObject
(
m
,
names
[
i
],
tmp
);
}
}
PyModule_AddIntConstant
(
m
,
"RCVALL_OFF"
,
RCVALL_OFF
);
PyModule_AddIntConstant
(
m
,
"RCVALL_ON"
,
RCVALL_ON
);
...
...
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