MCPcopy Create free account
hub / github.com/rthalley/dnspython / send_udp

Function send_udp

dns/asyncquery.py:91–118  ·  view source on GitHub ↗

Send a DNS message to the specified UDP socket. *sock*, a ``dns.asyncbackend.DatagramSocket``. *what*, a ``bytes`` or ``dns.message.Message``, the message to send. *destination*, a destination tuple appropriate for the address family of the socket, specifying where to send the que

(
    sock: dns.asyncbackend.DatagramSocket,
    what: dns.message.Message | bytes,
    destination: Any,
    expiration: float | None = None,
)

Source from the content-addressed store, hash-verified

89
90
91async def send_udp(
92 sock: dns.asyncbackend.DatagramSocket,
93 what: dns.message.Message | bytes,
94 destination: Any,
95 expiration: float | None = None,
96) -> Tuple[int, float]:
97 """Send a DNS message to the specified UDP socket.
98
99 *sock*, a ``dns.asyncbackend.DatagramSocket``.
100
101 *what*, a ``bytes`` or ``dns.message.Message``, the message to send.
102
103 *destination*, a destination tuple appropriate for the address family
104 of the socket, specifying where to send the query.
105
106 *expiration*, a ``float`` or ``None``, the absolute time at which
107 a timeout exception should be raised. If ``None``, no timeout will
108 occur. The expiration value is meaningless for the asyncio backend, as
109 asyncio's transport sendto() never blocks.
110
111 Returns an ``(int, float)`` tuple of bytes sent and the sent time.
112 """
113
114 if isinstance(what, dns.message.Message):
115 what = what.to_wire()
116 sent_time = time.time()
117 n = await sock.sendto(what, destination, _timeout(expiration, sent_time))
118 return (n, sent_time)
119
120
121async def receive_udp(

Callers 1

udpFunction · 0.70

Calls 4

_timeoutFunction · 0.85
timeMethod · 0.80
to_wireMethod · 0.45
sendtoMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…