(self, conn, address)
| 575 | return future |
| 576 | |
| 577 | def connect(self, conn, address): |
| 578 | if conn.type == socket.SOCK_DGRAM: |
| 579 | # WSAConnect will complete immediately for UDP sockets so we don't |
| 580 | # need to register any IOCP operation |
| 581 | _overlapped.WSAConnect(conn.fileno(), address) |
| 582 | fut = self._loop.create_future() |
| 583 | fut.set_result(None) |
| 584 | return fut |
| 585 | |
| 586 | self._register_with_iocp(conn) |
| 587 | # The socket needs to be locally bound before we call ConnectEx(). |
| 588 | try: |
| 589 | _overlapped.BindLocal(conn.fileno(), conn.family) |
| 590 | except OSError as e: |
| 591 | if e.winerror != errno.WSAEINVAL: |
| 592 | raise |
| 593 | # Probably already locally bound; check using getsockname(). |
| 594 | if conn.getsockname()[1] == 0: |
| 595 | raise |
| 596 | ov = _overlapped.Overlapped(NULL) |
| 597 | ov.ConnectEx(conn.fileno(), address) |
| 598 | |
| 599 | def finish_connect(trans, key, ov): |
| 600 | ov.getresult() |
| 601 | # Use SO_UPDATE_CONNECT_CONTEXT so getsockname() etc work. |
| 602 | conn.setsockopt(socket.SOL_SOCKET, |
| 603 | _overlapped.SO_UPDATE_CONNECT_CONTEXT, 0) |
| 604 | return conn |
| 605 | |
| 606 | return self._register(ov, conn, finish_connect) |
| 607 | |
| 608 | def sendfile(self, sock, file, offset, count): |
| 609 | self._register_with_iocp(sock) |
no test coverage detected