MCPcopy Index your code
hub / github.com/python/cpython / sock_sendto

Method sock_sendto

Lib/asyncio/selector_events.py:586–611  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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():

Callers

nothing calls this directly

Calls 8

_add_writerMethod · 0.95
partialMethod · 0.80
gettimeoutMethod · 0.45
sendtoMethod · 0.45
create_futureMethod · 0.45
filenoMethod · 0.45
add_done_callbackMethod · 0.45

Tested by

no test coverage detected