summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-04-04 14:10:20 (GMT)
committerGuido van Rossum <guido@python.org>2000-04-04 14:10:20 (GMT)
commit527c9bd32a5ee812516f7fce4d3e39e1ffe11c01 (patch)
tree37da7d61275007031d42c09308fa09a8d61cf82d /Modules/socketmodule.c
parent1571a1e34b68f0f3384ced27ee692e200d219a9e (diff)
downloadcpython-527c9bd32a5ee812516f7fce4d3e39e1ffe11c01.zip
cpython-527c9bd32a5ee812516f7fce4d3e39e1ffe11c01.tar.gz
cpython-527c9bd32a5ee812516f7fce4d3e39e1ffe11c01.tar.bz2
Put back multi-arg capability on connect/connect_ex/bind, for
backwards compatibility, and to avoid a revolution.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index a6f4664..766edf7 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -66,12 +66,15 @@ Module interface:
- a UNIX domain socket address is a string specifying the pathname
Socket methods:
+(NB: an argument list of the form (sockaddr...) means that multiple
+arguments are treated the same as a single tuple argument, for backwards
+compatibility.)
- s.accept() --> new socket object, sockaddr
-- s.bind(sockaddr) --> None
+- s.bind(sockaddr...) --> None
- s.close() --> None
-- s.connect(sockaddr) --> None
-- s.connect_ex(sockaddr) --> 0 or errno (handy for e.g. async connect)
+- s.connect(sockaddr...) --> None
+- s.connect_ex(sockaddr...) --> 0 or errno (handy for e.g. async connect)
- s.fileno() --> file descriptor
- s.dup() --> same as socket.fromfd(os.dup(s.fileno(), ...)
- s.getpeername() --> sockaddr
@@ -849,7 +852,7 @@ If a nonzero buffersize argument is given, the return value is a\n\
string of that length; otherwise it is an integer.";
-/* s.bind(sockaddr) method */
+/* s.bind(sockaddr...) method */
static PyObject *
BUILD_FUNC_DEF_2(PySocketSock_bind,PySocketSockObject *,s, PyObject *,args)
@@ -857,10 +860,7 @@ BUILD_FUNC_DEF_2(PySocketSock_bind,PySocketSockObject *,s, PyObject *,args)
struct sockaddr *addr;
int addrlen;
int res;
- PyObject *addro;
- if (!PyArg_ParseTuple(args, "O:bind", &addro))
- return NULL;
- if (!getsockaddrarg(s, addro, &addr, &addrlen))
+ if (!getsockaddrarg(s, args, &addr, &addrlen))
return NULL;
Py_BEGIN_ALLOW_THREADS
res = bind(s->sock_fd, addr, addrlen);
@@ -903,7 +903,7 @@ static char close_doc[] =
Close the socket. It cannot be used after this call.";
-/* s.connect(sockaddr) method */
+/* s.connect(sockaddr...) method */
static PyObject *
BUILD_FUNC_DEF_2(PySocketSock_connect,PySocketSockObject *,s, PyObject *,args)
@@ -911,10 +911,7 @@ BUILD_FUNC_DEF_2(PySocketSock_connect,PySocketSockObject *,s, PyObject *,args)
struct sockaddr *addr;
int addrlen;
int res;
- PyObject *addro;
- if (!PyArg_ParseTuple(args, "O:connect", &addro))
- return NULL;
- if (!getsockaddrarg(s, addro, &addr, &addrlen))
+ if (!getsockaddrarg(s, args, &addr, &addrlen))
return NULL;
Py_BEGIN_ALLOW_THREADS
res = connect(s->sock_fd, addr, addrlen);
@@ -932,7 +929,7 @@ Connect the socket to a remote address. For IP sockets, the address\n\
is a pair (host, port).";
-/* s.connect_ex(sockaddr) method */
+/* s.connect_ex(sockaddr...) method */
static PyObject *
BUILD_FUNC_DEF_2(PySocketSock_connect_ex,PySocketSockObject *,s, PyObject *,args)
@@ -940,10 +937,7 @@ BUILD_FUNC_DEF_2(PySocketSock_connect_ex,PySocketSockObject *,s, PyObject *,args
struct sockaddr *addr;
int addrlen;
int res;
- PyObject *addro;
- if (!PyArg_ParseTuple(args, "O:connect_ex", &addro))
- return NULL;
- if (!getsockaddrarg(s, addro, &addr, &addrlen))
+ if (!getsockaddrarg(s, args, &addr, &addrlen))
return NULL;
Py_BEGIN_ALLOW_THREADS
res = connect(s->sock_fd, addr, addrlen);
@@ -1310,13 +1304,13 @@ of the socket (flag == 1), or both ends (flag == 2).";
static PyMethodDef PySocketSock_methods[] = {
{"accept", (PyCFunction)PySocketSock_accept, 1,
accept_doc},
- {"bind", (PyCFunction)PySocketSock_bind, 1,
+ {"bind", (PyCFunction)PySocketSock_bind, 0,
bind_doc},
{"close", (PyCFunction)PySocketSock_close, 1,
close_doc},
- {"connect", (PyCFunction)PySocketSock_connect, 1,
+ {"connect", (PyCFunction)PySocketSock_connect, 0,
connect_doc},
- {"connect_ex", (PyCFunction)PySocketSock_connect_ex, 1,
+ {"connect_ex", (PyCFunction)PySocketSock_connect_ex, 0,
connect_ex_doc},
#ifndef NO_DUP
{"dup", (PyCFunction)PySocketSock_dup, 1,