summaryrefslogtreecommitdiff
path: root/overlapped.c
diff options
context:
space:
mode:
authorRichard Oudkerk <shibturn@gmail.com>2013-10-15 22:22:00 +0100
committerRichard Oudkerk <shibturn@gmail.com>2013-10-15 22:22:00 +0100
commit014f2a4de61ca24c0fb2ffed333f96b1a61d01c2 (patch)
treea03f0f7c94bbdc98243872f35079bfc57ddfc0ed /overlapped.c
parentc89e68d489adcdbdb5184355c376fbe92676de0b (diff)
downloadtrollius-014f2a4de61ca24c0fb2ffed333f96b1a61d01c2.tar.gz
Make BindLocal() take an argument for the family of the socket.
Diffstat (limited to 'overlapped.c')
-rw-r--r--overlapped.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/overlapped.c b/overlapped.c
index b5be63a..6a1d9e4 100644
--- a/overlapped.c
+++ b/overlapped.c
@@ -233,29 +233,28 @@ overlapped_PostQueuedCompletionStatus(PyObject *self, PyObject *args)
PyDoc_STRVAR(
BindLocal_doc,
- "BindLocal(handle, length_of_address_tuple) -> None\n\n"
+ "BindLocal(handle, family) -> None\n\n"
"Bind a socket handle to an arbitrary local port.\n"
- "If length_of_address_tuple is 2 then an AF_INET address is used.\n"
- "If length_of_address_tuple is 4 then an AF_INET6 address is used.");
+ "family should AF_INET or AF_INET6.\n");
static PyObject *
overlapped_BindLocal(PyObject *self, PyObject *args)
{
SOCKET Socket;
- int TupleLength;
+ int Family;
BOOL ret;
- if (!PyArg_ParseTuple(args, F_HANDLE "i", &Socket, &TupleLength))
+ if (!PyArg_ParseTuple(args, F_HANDLE "i", &Socket, &Family))
return NULL;
- if (TupleLength == 2) {
+ if (Family == AF_INET) {
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = 0;
addr.sin_addr.S_un.S_addr = INADDR_ANY;
ret = bind(Socket, (SOCKADDR*)&addr, sizeof(addr)) != SOCKET_ERROR;
- } else if (TupleLength == 4) {
+ } else if (Family == AF_INET6) {
struct sockaddr_in6 addr;
memset(&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;