Send data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determ
(self, sock, data, address)
| 584 | pos[0] = start |
| 585 | |
| 586 | async def sock_sendto(self, sock, data, address): |
| 587 | """Send data to the socket. |
| 588 | |
| 589 | The socket must be connected to a remote socket. This method continues |
| 590 | to send data from data until either all data has been sent or an |
| 591 | error occurs. None is returned on success. On error, an exception is |
| 592 | raised, and there is no way to determine how much data, if any, was |
| 593 | successfully processed by the receiving end of the connection. |
| 594 | """ |
| 595 | base_events._check_ssl_socket(sock) |
| 596 | if self._debug and sock.gettimeout() != 0: |
| 597 | raise ValueError("the socket must be non-blocking") |
| 598 | try: |
| 599 | return sock.sendto(data, address) |
| 600 | except (BlockingIOError, InterruptedError): |
| 601 | pass |
| 602 | |
| 603 | fut = self.create_future() |
| 604 | fd = sock.fileno() |
| 605 | self._ensure_fd_no_transport(fd) |
| 606 | # use a trick with a list in closure to store a mutable state |
| 607 | handle = self._add_writer(fd, self._sock_sendto, fut, sock, data, |
| 608 | address) |
| 609 | fut.add_done_callback( |
| 610 | functools.partial(self._sock_write_done, fd, handle=handle)) |
| 611 | return await fut |
| 612 | |
| 613 | def _sock_sendto(self, fut, sock, data, address): |
| 614 | if fut.done(): |
nothing calls this directly
no test coverage detected