Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 1.1 KB

index.rst

File metadata and controls

54 lines (37 loc) · 1.1 KB

Examples

Client

import asyncio
import asyncudp

async def main():
    sock = await asyncudp.create_socket(remote_addr=('127.0.0.1', 9999))
    sock.sendto(b'Hello!')
    print(await sock.recvfrom())
    sock.close()

asyncio.run(main())

Server

import asyncio
import asyncudp

async def main():
    sock = await asyncudp.create_socket(local_addr=('127.0.0.1', 9999))

    while True:
        data, addr = await sock.recvfrom()
        print(data, addr)
        sock.sendto(data, addr)

asyncio.run(main())

Functions and classes

asyncudp.create_socket

asyncudp.Socket

asyncudp.Socket.close

asyncudp.Socket.sendto

asyncudp.Socket.recvfrom