On this page
asyncio.DatagramProtocol
Prev: asyncio.current_task | Up: asyncio | Next: asyncio.DatagramTransport
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.DatagramProtocol
Tags: #public #python3 #stdlib #asyncio
Import
import asyncio
from asyncio import DatagramProtocol
Signature & Overview
asyncio.DatagramProtocol()
Interface for datagram protocol.
Methods & Attributes
DatagramProtocol.connection_lost(self, exc)— Called when the connection is lost or closed.DatagramProtocol.connection_made(self, transport)— Called when a connection is made.DatagramProtocol.datagram_received(self, data, addr)— Called when some datagram is received.DatagramProtocol.error_received(self, exc)— Called when a send or receive operation raises an OSError.DatagramProtocol.pause_writing(self)— Called when the transport's buffer goes over the high-water mark.DatagramProtocol.resume_writing(self)— Called when the transport's buffer drains below the low-water mark.
Usage
import asyncio
# Low-level UDP protocol interface (paired with loop.create_datagram_endpoint)
assert issubclass(asyncio.DatagramProtocol, asyncio.BaseProtocol)
Gotchas
- Used for UDP sockets: Override
datagram_received(self, data, addr)to handle incoming packets.
REPL Inspect
from asyncio import DatagramProtocol
help(DatagramProtocol)
Linked from
Related notes
- tuts/python3/stdlib_module/asyncio/current_task Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/DatagramTransport Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractEventLoop Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractServer Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/all_tasks Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/as_completed Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/Barrier shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseEventLoop shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseProtocol shared tags: #asyncio, #stdlib