pyremoteplay.socket module
Async UDP Sockets. Based on asyncudp (https://github.com/eerimoq/asyncudp).
- class pyremoteplay.socket.AsyncBaseProtocol
Bases:
BaseProtocolBase Protocol. Do not use directly.
- connection_made(transport)
Connection Made.
- connection_lost(exc)
Connection Lost.
- error_received(exc)
Error Received.
- async recvfrom(timeout=None)
Return received data and addr.
- async recv(timeout=None)
Return received data.
- Return type
Optional[bytes]
- sendto(data, *_)
Send packet.
- set_callback(callback)
Set callback for data received.
Setting this will flush packet received packet queue.
recv()will always return None.- Parameters
callback – callback for data received
- close()
Close transport.
- get_extra_info(name, default=None)
Return Extra Info.
- Return type
Any
- property has_callback
Return True if callback is set.
- property opened: bool
Return True if opened.
- Return type
bool
- property closed: bool
Return True if closed.
- Return type
bool
- property sock: socket
Return sock.
- Return type
socket
- class pyremoteplay.socket.AsyncTCPProtocol
Bases:
Protocol,AsyncBaseProtocolUDP Protocol.
- connection_made(transport)
Connection Made.
- data_received(data)
Called when some data is received.
The argument is a bytes object.
- sendto(data, *_)
Send packet to address.
- class pyremoteplay.socket.AsyncUDPProtocol
Bases:
DatagramProtocol,AsyncBaseProtocolUDP Protocol.
- connection_made(transport)
Connection Made.
- datagram_received(data, addr)
Datagram Received.
- sendto(data, addr=None)
Send packet to address.
- class pyremoteplay.socket.AsyncBaseSocket(protocol, local_addr=None)
Bases:
objectAsync Base socket. Do not use directly.
- async classmethod create(local_addr=None, remote_addr=None, *, sock=None, **kwargs)
Create and return Socket.
- close()
Close the socket.
- sendto(data, addr=None)
Send Packet
- async recv(timeout=None)
Receive a packet.
- Return type
Optional[bytes]
- async recvfrom(timeout=None)
Receive a packet and address.
- get_extra_info(name, default=None)
Return Extra Info.
- Return type
Any
- setsockopt(_AsyncBaseSocket__level, _AsyncBaseSocket__optname, _AsyncBaseSocket__value, /)
Set Sock Opt.
- set_callback(callback)
Set callback for data received.
Setting this will flush packet received packet queue.
recv()will always return None.- Parameters
callback – callback for data received
- property opened: bool
Return True if opened.
- Return type
bool
- property closed: bool
Return True if closed.
- Return type
bool
- property sock: socket
Return socket.
- Return type
socket
- property local_addr: tuple[str, int]
Return local address.
- class pyremoteplay.socket.AsyncTCPSocket(protocol, local_addr=None)
Bases:
AsyncBaseSocketAsync TCP socket.
- async classmethod create(local_addr=None, remote_addr=None, *, sock=None, **kwargs)
Create and return Socket.
- send(data)
Send Packet.
- class pyremoteplay.socket.AsyncUDPSocket(protocol, local_addr=None)
Bases:
AsyncBaseSocketAsync UDP socket.
- async classmethod create(local_addr=None, remote_addr=None, *, sock=None, reuse_port=None, allow_broadcast=None, **kwargs)
Create and return UDP Socket.
- set_broadcast(enabled)
Set Broadcast enabled.