OLD | NEW |
| (Empty) |
1 # Copyright (c) 2008 Twisted Matrix Laboratories. | |
2 # See LICENSE for details. | |
3 | |
4 | |
5 def connect(long s, object addr, object obj): | |
6 cdef int family, rc | |
7 cdef myOVERLAPPED *ov | |
8 cdef sockaddr name | |
9 | |
10 if not have_connectex: | |
11 raise ValueError, 'ConnectEx is not available on this system' | |
12 | |
13 family = getAddrFamily(s) | |
14 if family == AF_INET: | |
15 fillinetaddr(<sockaddr_in *>&name, addr) | |
16 else: | |
17 raise ValueError, 'unsupported address family' | |
18 name.sa_family = family | |
19 | |
20 ov = makeOV() | |
21 if obj is not None: | |
22 ov.obj = <PyObject *>obj | |
23 | |
24 rc = lpConnectEx(s, &name, sizeof(name), NULL, 0, NULL, <OVERLAPPED *>ov) | |
25 | |
26 if not rc: | |
27 rc = WSAGetLastError() | |
28 if rc != ERROR_IO_PENDING: | |
29 return rc | |
30 | |
31 # operation is in progress | |
32 Py_XINCREF(obj) | |
33 return rc | |
34 | |
OLD | NEW |