hio.core.udp.udping =================== .. py:module:: hio.core.udp.udping .. autoapi-nested-parse:: hio.core.udp.udping Module Module Contents --------------- .. py:class:: Peer(*, name='main', ha=None, host='127.0.0.1', port=55000, bc=None, bs=None, wl=None, bcast=False, reopen=False, **kwa) Bases: :py:obj:`hio.hioing.Mixin` Class to manage non blocking I/O on UDP socket. Class Attributes: BufSize (int): used to set default buffer size for transport datagram buffers MaxGramSize (int): max bytes in in datagram for this transport .. attribute:: name unique identifier of peer for management purposes :type: str .. attribute:: ha host address of form (host,port) of type (str, int) of this peer's socket address. :type: tuple .. attribute:: bc count of transport buffers of MaxGramSize :type: int | None .. attribute:: bs buffer size :type: int .. attribute:: wl instance ref for debug logging of over the wire tx and rx :type: WireLog .. attribute:: ls local socket of this Peer :type: socket.socket .. attribute:: opened True local socket is created and opened. False otherwise :type: bool .. attribute:: bcast True enables sending to broadcast addresses from local socket False otherwise :type: bool Properties: host (str): element of .ha duple port (int): element of .ha duple path (tuple): .ha (host, port) alias to match .uxd .. py:property:: path Property that returns .ha duple stub to match uxd interface .. py:property:: host Property that returns host in .ha duple .. py:property:: port Property that returns port in .ha duple .. py:method:: actualBufSizes() Returns duple of the the actual socket send and receive buffer size (send, receive) .. py:method:: open() Opens socket in non blocking mode. if socket not closed properly, binding socket gets error OSError: (48, 'Address already in use') .. py:method:: reopen(**kwa) Idempotently open socket .. py:method:: close() Closes socket. .. py:method:: receive(**kwa) Perform non blocking read on socket. :returns: tuple of form (data, sa) if no data then returns (b'',None) but always returns a tuple with two elements .. py:method:: send(data, dst, **kwa) Perform non blocking send on socket. :returns: count of bytes actually sent, may be less than len(data). :rtype: cnt (int) :param data: payload to send (txbs) :type data: bytes | bytearray :param dst: udp destination addr duple of form (host: str, port: int) :type dst: str .. py:function:: openPeer(cls=None, name='test', **kwa) Wrapper to create and open UDP Peer instances When used in with statement block, calls .close() on exit of with block :param cls: instance of subclass instance :type cls: Class :param name: unique identifier of peer. Enables management of Peer sockets by name. :type name: str Usage: with openPeer() as peer0: peer0.receive() with openPeer(cls=PeerBig) as peer0: peer0.receive() .. py:class:: PeerDoer(peer, **kwa) Bases: :py:obj:`hio.base.doing.Doer` Basic UDP Peer Doer Stub Override in Subclass To test in WingIde must configure Debug I/O to use external console See Doer for inherited attributes, properties, and methods. See Doer for inherited attributes, properties, and methods. .. attribute:: .peer is UDP Peer instance .. py:method:: enter(*, temp=None) Do 'enter' context actions. Override in subclass. Not a generator method. Set up resources. Comparable to context manager enter. temp is bool or None. True means use temporary file resources if any. None means ignore parameter value and use self.temp. Inject temp or self.temp into file resources here if any. .. py:method:: recur(tyme) Override to service receives and sends. .. py:method:: exit() Close peer resources.