hio.core.tcp.clienting

hio.core.tcp.clienting Module

Module Contents

hio.core.tcp.clienting.openClient(cls=None, **kwa)

Wrapper to create and open TCP Client instances When used in with statement block, calls .close() on exit of with block

Parameters:

instance (cls is Class instance of subclass)

Usage:

with openClient() as client0:
    client0.accept()

with openClient(cls=ClientTls) as client0:
    client0.accept()
class hio.core.tcp.clienting.Client(tymeout=None, ha=None, host='127.0.0.1', port=56000, reconnectable=None, bs=8096, txbs=None, rxbs=None, wl=None, **kwa)

Bases: hio.base.tyming.Tymee

Nonblocking TCP Socket Client Class.

See tyming.Tymee for inherited attributes, properties, and methods

Attributes:

Properties:

Methods:

property host

Property that returns host in .ha duple

property port

Property that returns port in .ha duple

property accepted

Property that returns accepted state of TCP socket

property connected

Property that returns connected state of TCP socket Non-tls tcp is connected when accepted

wind(tymth)

Inject new tymist.tymth as new ._tymth. Changes tymist.tyme base. Updates winds .tymer .tymth

actualBufSizes()

Returns duple of the the actual socket send and receive buffer size (send, receive)

open()

Opens connection socket in non blocking mode.

if socket not closed properly, binding socket gets error

OSError: (48, ‘Address already in use’)

reopen()

Idempotently opens socket

shutdown(how=socket.SHUT_RDWR)

Shutdown connected socket .cs

shutdownSend()

Shutdown send on connected socket .cs

shutdownReceive()

Shutdown receive on connected socket .cs

close()

Shutdown and close connected socket .cs

refresh()

Restart timer

accept()

Attempt nonblocking acceptance connect to .ha Returns True if successful Returns False if not so try again later

connect()

Attempt nonblocking connect to .ha Returns True if successful Returns False if not so try again later For non-TLS tcp connect is done when accepted This is placeholder for subclass Tls

serviceConnect()

Service connection attempt If not already connected make a nonblocking attempt Returns .connected

receive()

Perform non blocking receive from connected socket .cs

If no data then returns None If connection closed then returns empty Otherwise returns data data is string in python2 and bytes in python3

serviceReceives()

Service receives until no more

serviceReceiveOnce()

Retrieve from server only one reception

clearRxbs()

Clear .rxbs

send(data)

Perform non blocking send on connected socket .cs. Return number of bytes sent data is string in python2 and bytes in python3

tx(data)

Copy data onto .txbs, .extend copies data.

serviceSends()

Service sends (transmits) of data in .txbs bytearray Attempt to send all of .txbs. Delete what is actually sent.

service()

Service connect, txbs, and receives.

class hio.core.tcp.clienting.ClientTls(context=None, version=None, certify=None, hostify=None, certedhost='', keypath=None, certpath=None, cafilepath=None, **kwa)

Bases: Client

Outgoer with Nonblocking TLS/SSL support Nonblocking TCP Socket Client Class.

Attributes:

Properties:

Methods:

property connected

Property that returns connected state of TCP socket TLS tcp is connected when accepted and handshake completed

close()

Shutdown and close connected socket .cs

wrap()

Wrap socket .cs in ssl context

handshake()

Attempt nonblocking ssl handshake to .ha Returns True if successful Returns False if not so try again later

connect()

Attempt nonblocking connect to .ha Returns True if successful Returns False if not so try again later Connected when both accepted connection and TLS handshake complete

receive()

Perform non blocking receive from connected socket .cs

If no data then returns None If connection closed then returns ‘’ Otherwise returns data data is string in python2 and bytes in python3

send(data)

Perform non blocking send on connected socket .cs. Return number of bytes sent data is string in python2 and bytes in python3

class hio.core.tcp.clienting.ClientDoer(client, **kwa)

Bases: hio.base.doing.Doer

Basic TCP Client Doer

See Doer for inherited attributes, properties, and methods.

.client is TCP Client instance
wind(tymth)

Inject new tymist.tymth as new ._tymth. Changes tymist.tyme base. Updates winds .tymer .tymth

enter(*, temp=None)

Do ‘enter’ context actions. Set up resources. Comparable to context manager enter.

Parameters:

temp (bool | None) – True means use temporary file resources if any None means ignore parameter value. Use self.temp

Inject temp or self.temp into file resources here if any

recur(tyme)

Do ‘recur’ context actions. Override in subclass. Regular method that perform repetitive actions once per invocation. Assumes resource setup in .enter() and resource takedown in .exit() (see ReDoer below for example of .recur that is a generator method)

Returns completion state of recurrence actions: True means done, False means continue.

Doist provides the time value.

.recur maybe implemented by a subclass either as a non-generator method or a generator method. This stub here is as a non-generator method. The base class .do detects which type:

If non-generator .do method runs .recur method once per iteration
    until .recur returns (True)
If generator .do method runs .recur with (yield from) until .recur
    returns (see ReDoer for example of generator .recur)
exit()

Do ‘exit’ context actions. Override in subclass. Not a generator method. Clean up resources. Comparable to context manager exit. Called by finally after normal return, close, or abort. After .exit() do returns resulting in StopIteration.