Receive a datagram from a datagram socket. The return value is a tuple of (bytes, address) representing the datagram received and the address it came from. The maximum amount of data to be received at once is specified by nbytes.
(self, sock, bufsize)
| 449 | fut.set_result(nbytes) |
| 450 | |
| 451 | async def sock_recvfrom(self, sock, bufsize): |
| 452 | """Receive a datagram from a datagram socket. |
| 453 | |
| 454 | The return value is a tuple of (bytes, address) representing the |
| 455 | datagram received and the address it came from. |
| 456 | The maximum amount of data to be received at once is specified by |
| 457 | nbytes. |
| 458 | """ |
| 459 | base_events._check_ssl_socket(sock) |
| 460 | if self._debug and sock.gettimeout() != 0: |
| 461 | raise ValueError("the socket must be non-blocking") |
| 462 | try: |
| 463 | return sock.recvfrom(bufsize) |
| 464 | except (BlockingIOError, InterruptedError): |
| 465 | pass |
| 466 | fut = self.create_future() |
| 467 | fd = sock.fileno() |
| 468 | self._ensure_fd_no_transport(fd) |
| 469 | handle = self._add_reader(fd, self._sock_recvfrom, fut, sock, bufsize) |
| 470 | fut.add_done_callback( |
| 471 | functools.partial(self._sock_read_done, fd, handle=handle)) |
| 472 | return await fut |
| 473 | |
| 474 | def _sock_recvfrom(self, fut, sock, bufsize): |
| 475 | # _sock_recvfrom() can add itself as an I/O callback if the operation |
nothing calls this directly
no test coverage detected