Module qlibs.net.asyncsocket

Async socket library

class qlibs.net.asyncsocket.AsyncSocket(socket: _socket.socket)

Async socket - writing and reading don’t block.

Most useful when it is the only socket you need, consider using select if you need more sockets

TCP version

accept() Union[Tuple[_socket.socket, Any], Tuple[None, None]]

Accept connection asynchronously. Returns (None, None) is not ready

close()
empty() bool

True if no values to send left

extra = None
fileno()
recv(amount: int) bytes

Try to recieve data from socket

send(data: Optional[bytes] = None) int

Try to send data to socket; this is buffered

class qlibs.net.asyncsocket.AsyncUDPSocket(socket)

Async socket - writing and reading don’t block

Most useful when it is the only socket you need, consider using select if you need more sockets

UDP version

extra = None
recv(amount=8192)

Recieve data, (None, None) returned if no data available

sendto(data, adress)

Try to send packet to adrees; no buffer

sendto_buff(data, adress)

Try to send packet to adress; with buffer

class qlibs.net.asyncsocket.PacketSocket(socket, processor, *args)

Socket for handling packets, passes recieved bytes to generator

close()
property closed
empty()

True if no values to send left

extra = None
fileno()
recv(size=8192)

Recieve data from socket and feed it to generator

send(data: Optional[bytes] = None)

Try to send data to socket; this is buffered

class qlibs.net.asyncsocket.SelSockType(value)

An enumeration.

ACCEPTER = 'accept'
NORMAL = 'normal'
class qlibs.net.asyncsocket.ServerSelector(listener: _socket.socket, on_connect: Callable, on_read: Callable)
register(asock: Union[qlibs.net.asyncsocket.AsyncSocket, qlibs.net.asyncsocket.PacketSocket])
select(timeout=None)
property socket_iterator
unregister(asock: Union[qlibs.net.asyncsocket.AsyncSocket, qlibs.net.asyncsocket.PacketSocket])
qlibs.net.asyncsocket.bytes_packet_reciever(sock)
qlibs.net.asyncsocket.bytes_packet_sender(data)