From cbd9300f7fd9aac6305d3e4076ba55350cfb5c87 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 17 Aug 2025 13:30:37 +0200 Subject: [PATCH] docs update --- .../unittest.pdf | 0 _docs_/genindex.html | 129 ++++ _docs_/objects.inv | Bin 242 -> 466 bytes _docs_/py-modindex.html | 238 +++++++ _docs_/search.html | 6 + _docs_/searchindex.js | 2 +- _docs_/tcp_socket.html | 603 +++++++++++++++++- 7 files changed, 975 insertions(+), 3 deletions(-) create mode 100644 _docs_/_downloads/116764b172e3896101367c053dc35373/unittest.pdf create mode 100644 _docs_/py-modindex.html diff --git a/_docs_/_downloads/116764b172e3896101367c053dc35373/unittest.pdf b/_docs_/_downloads/116764b172e3896101367c053dc35373/unittest.pdf new file mode 100644 index 0000000..e69de29 diff --git a/_docs_/genindex.html b/_docs_/genindex.html index 263bdd4..fa0db37 100644 --- a/_docs_/genindex.html +++ b/_docs_/genindex.html @@ -77,6 +77,9 @@
  • index
  • +
  • + modules |
  • Python logo
  • Python »
  • @@ -122,8 +125,131 @@

    Index

    + C + | D + | I + | M + | R + | S + | T
    +

    C

    + + + +
    + +

    D

    + + +
    + +

    I

    + + + +
    + +

    M

    + + +
    + +

    R

    + + + +
    + +

    S

    + + +
    + +

    T

    + + + +
    +
    @@ -152,6 +278,9 @@
  • index
  • +
  • + modules |
  • Python logo
  • Python »
  • diff --git a/_docs_/objects.inv b/_docs_/objects.inv index 9d8ab7718d0f43c86a17ccbea47d49bc4738dcc9..ed2dedd75dcdd5520dcb46a1e1a16f3c807a897d 100644 GIT binary patch delta 355 zcmV-p0i6Ew0n!7Icz>;xO>e?542JLgib&hFXk57=){RPSL8C~!MQLKS5h1M-gT}vK zL&jA0p{;>iYWsQX4>>{JQrqw?AZd@&T_g4i$OFMo^SH*Hy7P|coi3aG7QYvLszZx zheTJhpH^7j0bJd-U=Cn{p#S`>0xh+GH)2st6)QoJXhP1`QyfX$an#-PKSZ|2=cS)-ihc7_N^?@7dXQuZXbY$;$;i(`)m@yLSd^TBsu3av(Gv`j4@gW;t53;K2B}7fLUbUhDo9Mu25AHUTuWQ~9D+C+ diff --git a/_docs_/py-modindex.html b/_docs_/py-modindex.html new file mode 100644 index 0000000..ee4d88b --- /dev/null +++ b/_docs_/py-modindex.html @@ -0,0 +1,238 @@ + + + + + + + Python Module Index — tcp_socket documentation + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    +
    +
    +
    + + +

    Python Module Index

    + +
    + t +
    + + + + + + + +
     
    + t
    + tcp_socket +
    + + +
    +
    +
    +
    + +
    +
    + + + + + \ No newline at end of file diff --git a/_docs_/search.html b/_docs_/search.html index de533a9..42e8793 100644 --- a/_docs_/search.html +++ b/_docs_/search.html @@ -67,6 +67,9 @@
  • index
  • +
  • + modules |
  • Python logo
  • Python »
  • @@ -141,6 +144,9 @@
  • index
  • +
  • + modules |
  • Python logo
  • Python »
  • diff --git a/_docs_/searchindex.js b/_docs_/searchindex.js index cb8e7a8..ca4698d 100644 --- a/_docs_/searchindex.js +++ b/_docs_/searchindex.js @@ -1 +1 @@ -Search.setIndex({"alltitles":{"tcp_socket package":[[0,null]]},"docnames":["tcp_socket"],"envversion":{"sphinx":65,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["tcp_socket.rst"],"indexentries":{},"objects":{},"objnames":{},"objtypes":{},"terms":{},"titles":["tcp_socket package"],"titleterms":{"packag":0,"tcp_socket":0}}) \ No newline at end of file +Search.setIndex({"alltitles":{"tcp_socket (TCP Socket)":[[0,"tcp-socket-tcp-socket"]],"tcp_socket package":[[0,null]]},"docnames":["tcp_socket"],"envversion":{"sphinx":65,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["tcp_socket.rst"],"indexentries":{},"objects":{"":[[0,0,0,"-","tcp_socket"]],"tcp_socket":[[0,1,1,"","tcp_base"],[0,1,1,"","tcp_base_stp"],[0,1,1,"","tcp_client"],[0,1,1,"","tcp_client_stp"],[0,1,1,"","tcp_server"],[0,1,1,"","tcp_server_stp"]],"tcp_socket.tcp_base":[[0,2,1,"","COM_TIMEOUT"],[0,2,1,"","DEFAULT_CHANNEL_NAME"],[0,2,1,"","IS_CLIENT"],[0,2,1,"","RX_LENGTH"],[0,3,1,"","client_address"],[0,3,1,"","close"],[0,3,1,"","init_channel_name"],[0,3,1,"","is_connected"],[0,3,1,"","receive"],[0,3,1,"","register_callback"],[0,3,1,"","register_connect_callback"],[0,3,1,"","register_disconnect_callback"],[0,3,1,"","send"]],"tcp_socket.tcp_base_stp":[[0,3,1,"","receive"],[0,3,1,"","send"]],"tcp_socket.tcp_client":[[0,2,1,"","IS_CLIENT"],[0,3,1,"","reconnect"]]},"objnames":{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","attribute","Python attribute"],"3":["py","method","Python method"]},"objtypes":{"0":"py:module","1":"py:class","2":"py:attribute","3":"py:method"},"terms":{"":0,"0":0,"1":0,"127":0,"17000":0,"17017":0,"20":0,"255":0,"3":0,"3a":0,"3c":0,"3e":0,"5":0,"61":0,"62":0,"63":0,"7":0,"The":0,"With":0,"abc":0,"abl":0,"address":0,"after":0,"alder":0,"all":0,"all_oth":0,"also":0,"append":0,"argument":0,"author":0,"avail":0,"b":0,"base":0,"been":0,"bool":0,"buffer":0,"byte":0,"c":0,"callback":0,"can":0,"chang":0,"channel":0,"channel_nam":0,"charact":0,"class":0,"clean":0,"clien":0,"client":0,"client_address":0,"close":0,"com_timeout":0,"comm":0,"commun":0,"connect":0,"creat":0,"data":0,"de":0,"debug":0,"def":0,"default_channel_nam":0,"default_logging_config":0,"descript":0,"design":0,"direct":0,"dirk":0,"document":0,"e":0,"end":0,"establish":0,"exampl":0,"execut":0,"exist":0,"fals":0,"first":0,"float":0,"from":0,"function":0,"g":0,"get":0,"given":0,"had":0,"host":0,"i":0,"identifi":0,"import":0,"info":0,"inform":0,"init_channel_nam":0,"initi":0,"instanc":0,"int":0,"ip":0,"is_client":0,"is_connect":0,"least":0,"listen":0,"log":0,"logger":0,"lost":0,"messag":0,"method":0,"mirror_callback":0,"mockeri":0,"modul":0,"more":0,"mount":0,"name":0,"need":0,"new":0,"none":0,"nopep8":0,"num":0,"number":0,"object":0,"one":0,"other":0,"otherwis":0,"over":0,"pack":0,"paramet":0,"parent":0,"path":0,"pattern":0,"port":0,"print":0,"receiv":0,"reconnect":0,"register_callback":0,"register_connect_callback":0,"register_disconnect_callback":0,"report":0,"repr":0,"return":0,"run":0,"rx":0,"rx_length":0,"rx_tx_log_lvl":0,"see":0,"send":0,"sent":0,"serial":0,"server":0,"start":0,"state":0,"statu":0,"store":0,"stp":0,"stp_state_escape_1":0,"stp_state_escape_2":0,"stp_state_idl":0,"stp_state_store_data":0,"str":0,"stream":0,"stringtool":0,"submodul":0,"sudo":0,"support":0,"sy":0,"sync":0,"tcp_base":0,"tcp_base_stp":0,"tcp_client":0,"tcp_client_stp":0,"tcp_server":0,"tcp_server_stp":0,"thi":0,"time":0,"timeout":0,"transfer":0,"true":0,"tx":0,"type":0,"unittest":0,"unpack":0,"up":0,"us":0,"usag":0,"via":0,"when":0,"which":0,"you":0},"titles":["tcp_socket package"],"titleterms":{"packag":0,"socket":0,"tcp":0,"tcp_socket":0}}) \ No newline at end of file diff --git a/_docs_/tcp_socket.html b/_docs_/tcp_socket.html index 8814c28..f6f073b 100644 --- a/_docs_/tcp_socket.html +++ b/_docs_/tcp_socket.html @@ -58,6 +58,45 @@ +
    +

    Table of Contents

    + + +

    This Page

      @@ -85,6 +124,9 @@
    • index
    • +
    • + modules |
    • Python logo
    • Python »
    • @@ -126,8 +168,523 @@
      -
      -

      tcp_socket package

      +
      +

      tcp_socket package

      +
      +

      tcp_socket (TCP Socket)

      +

      Author:

      + +

      Description:

      +
      +

      This Module supports a client/ server tcp socket connection.

      +
      +

      Submodules:

      + +

      Unittest:

      +
      +

      See also the unittest documentation.

      +
      +

      Module Documentation:

      +
      +
      +
      +class tcp_socket.tcp_base(host, port, channel_name=None, rx_tx_log_lvl=20)
      +

      Bases: object

      +

      This is the base class for other classes in this module.

      +
      +
      Parameters:
      +
        +
      • host (str) – The host IP for the TCP socket functionality

      • +
      • port (int) – The port for the TCP socket functionality

      • +
      • channel_name (str) – The name for the logging channel

      • +
      +
      +
      +
      +

      Note

      +

      This class is not designed for direct usage.

      +
      +
      +
      +COM_TIMEOUT = 0.5
      +
      + +
      +
      +DEFAULT_CHANNEL_NAME = 'all_others'
      +
      + +
      +
      +IS_CLIENT = False
      +
      + +
      +
      +RX_LENGTH = 255
      +
      + +
      +
      +client_address()
      +

      This method returns the address of the connected client.

      +
      +
      Returns:
      +

      The client address.

      +
      +
      Return type:
      +

      str

      +
      +
      +
      + +
      +
      +close()
      +

      This method closes the connected communication channel, if exists.

      +
      + +
      +
      +init_channel_name(channel_name=None)
      +

      With this Method, the channel name for logging can be changed.

      +
      +
      Parameters:
      +

      channel_name (str) – The name for the logging channel

      +
      +
      +
      + +
      +
      +is_connected()
      +

      With this Method the connection status can be identified.

      +
      +
      Returns:
      +

      True, if a connection is established, otherwise False.

      +
      +
      Return type:
      +

      bool

      +
      +
      +
      + +
      +
      +receive(timeout=1, num=None)
      +

      This method returns received data.

      +
      +
      Parameters:
      +
        +
      • timeout (float) – The timeout for receiving data (at least after the timeout the method returns data or None).

      • +
      • num (int) – the number of bytes to receive (use None to get all available data).

      • +
      +
      +
      Returns:
      +

      The received data.

      +
      +
      Return type:
      +

      bytes

      +
      +
      +
      + +
      +
      +register_callback(callback)
      +

      This method stores the callback which is executed, if data is available. You need to execute receive() of this instance +given as first argument.

      +
      +
      Parameters:
      +

      callback – The callback which will be executed, when data is available.

      +
      +
      +
      + +
      +
      +register_connect_callback(callback)
      +

      This method stores the callback which is executed, if a connection is established.

      +
      +
      Parameters:
      +

      callback – The callback which will be executed, when a connection is established.

      +
      +
      +
      + +
      +
      +register_disconnect_callback(callback)
      +

      This method stores the callback which is executed, after the connection is lost.

      +
      +
      Parameters:
      +

      callback – The callback which will be executed, after the connection is lost.

      +
      +
      +
      + +
      +
      +send(data, timeout=1)
      +

      This method sends data via the initiated communication channel.

      +
      +
      Parameters:
      +
        +
      • data (bytes) – The data to be send over the communication channel.

      • +
      • timeout (float) – The timeout for sending data (e.g. time to establish new connection).

      • +
      +
      +
      Returns:
      +

      True if data had been sent, otherwise False.

      +
      +
      Return type:
      +

      bool

      +
      +
      +
      + +
      + +
      +
      +class tcp_socket.tcp_base_stp(host, port, channel_name=None)
      +

      Bases: tcp_base

      +

      This is the base class for other classes in this module. See also parent tcp_base.

      +
      +
      Parameters:
      +
        +
      • host (str) – The host IP for the TCP socket functionality

      • +
      • port (int) – The port for the TCP socket functionality

      • +
      • channel_name (str) – The name for the logging channel

      • +
      +
      +
      +
      +

      Note

      +

      This class is not designed for direct usage.

      +
      +
      +
      +receive(timeout=1)
      +

      This method returns one received messages via the initiated communication channel.

      +
      +
      Parameters:
      +

      timeout (float) – The timeout for receiving data (at least after the timeout the method returns data or None).

      +
      +
      Returns:
      +

      The received data.

      +
      +
      Return type:
      +

      bytes

      +
      +
      +
      + +
      +
      +send(data, timeout=1)
      +

      This method sends one stp message via the initiated communication channel.

      +
      +
      Parameters:
      +
        +
      • data (bytes) – The message to be send over the communication channel.

      • +
      • timeout (float) – The timeout for sending data (e.g. time to establish new connection).

      • +
      +
      +
      Returns:
      +

      True if data had been sent, otherwise False.

      +
      +
      Return type:
      +

      bool

      +
      +
      +
      + +
      + +
      +
      +class tcp_socket.tcp_client(host, port, channel_name=None, rx_tx_log_lvl=20)
      +

      Bases: tcp_base

      +

      This class creates a tcp-client for transfering a serial stream of bytes (characters). See also parent tcp_base.

      +
      +
      Parameters:
      +
        +
      • host (str) – The host IP for the TCP socket functionality

      • +
      • port (int) – The port for the TCP socket functionality

      • +
      • channel_name (str) – The name for the logging channel

      • +
      +
      +
      +
      +

      Note

      +

      You need a running tcp_server listening at the given IP and Port to be able to communicate.

      +
      +

      Example:

      +
      import sys                  # nopep8
      +sys.path.append('../..')    # nopep8
      +import time
      +import tcp_socket
      +import report
      +
      +
      +def mirror_callback(tcp):
      +    tcp.send(tcp.receive())
      +
      +
      +report.default_logging_config()
      +
      +# Start the server
      +s = tcp_socket.tcp_server('127.0.0.1', 17000)
      +s.register_callback(mirror_callback)
      +
      +# Start the clien
      +c = tcp_socket.tcp_client('127.0.0.1', 17000)
      +c.send(b'abc')
      +print('The Client received: %s' % repr(c.receive()))
      +
      +
      +
         DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +    INFO - tcp_socket.all_others - comm-server: Server listening to 127.0.0.1:17000
      +    INFO - tcp_socket.all_others - comm-server: Connection established... (from 127.0.0.1:17000)
      +    INFO - tcp_socket.all_others - comm-client: Connection established... (to 127.0.0.1:17000)
      +   DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +    INFO - tcp_socket.all_others - comm-client: TX -> "(3): 61 62 63"
      +    INFO - tcp_socket.all_others - comm-server: RX <- "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +    INFO - tcp_socket.all_others - comm-server: TX -> "(3): 61 62 63"
      +    INFO - tcp_socket.all_others - comm-client: RX <- "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +The Client received: b'abc'
      +
      +
      +
      +
      +IS_CLIENT = True
      +
      + +
      +
      +reconnect()
      +
      + +
      + +
      +
      +class tcp_socket.tcp_client_stp(host, port, channel_name=None)
      +

      Bases: tcp_client, tcp_base_stp

      +

      This class creates a tcp-client for transfering a message. The bytes will be packed on send and unpacked on receive. See also parents tcp_client and tcp_base_stp. +See stringtools.stp for more information on packing and unpacking.

      +
      +
      Parameters:
      +
        +
      • host (str) – The host IP for the TCP socket functionality

      • +
      • port (int) – The port for the TCP socket functionality

      • +
      • channel_name (str) – The name for the logging channel

      • +
      +
      +
      +
      +

      Note

      +

      You need a running tcp_server_stp listening at the given IP and Port to be able to communicate.

      +
      +

      Example:

      +
      import sys                  # nopep8
      +sys.path.append('../..')    # nopep8
      +
      +import tcp_socket
      +import report
      +
      +
      +def mirror_callback(tcp):
      +    tcp.send(tcp.receive())
      +
      +
      +logger = report.default_logging_config()
      +
      +# Start the server
      +s = tcp_socket.tcp_server_stp('127.0.0.1', 17017)
      +s.register_callback(mirror_callback)
      +
      +# Start the client
      +c = tcp_socket.tcp_client_stp('127.0.0.1', 17017)
      +c.send(b'abc')
      +print('The Client received: %s' % repr(c.receive()))
      +
      +
      +
         DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +    INFO - tcp_socket.all_others - comm-server: Server listening to 127.0.0.1:17017
      +    INFO - tcp_socket.all_others - comm-client: Connection established... (to 127.0.0.1:17017)
      +    INFO - tcp_socket.all_others - comm-server: Connection established... (from 127.0.0.1:17017)
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-client: TX -> "(7): 3a 3c 61 62 63 3a 3e"
      +    INFO - tcp_socket.all_others - comm-client: TX -> "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-server: RX <- "(7): 3a 3c 61 62 63 3a 3e"
      +   DEBUG - stringtools.stp - STP: data sync (3a) received => changing state STP_STATE_IDLE -> STP_STATE_ESCAPE_1
      +   DEBUG - stringtools.stp - STP: start pattern (3a 3c) received => changing state STP_STATE_ESCAPE_1 -> STP_STATE_STORE_DATA
      +   DEBUG - stringtools.stp - STP: data sync (3a) received => changing state STP_STATE_STORE_DATA -> STP_STATE_ESCAPE_2
      +   DEBUG - stringtools.stp - STP: end pattern (3a 3e) received => storing message and changing state STP_STATE_ESCAPE_2 -> STP_STATE_IDLE
      +    INFO - stringtools.stp - STP: message identified - (3): 61 62 63
      +    INFO - tcp_socket.all_others - comm-server: RX  <- "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-server: TX -> "(7): 3a 3c 61 62 63 3a 3e"
      +    INFO - tcp_socket.all_others - comm-server: TX -> "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-client: RX <- "(7): 3a 3c 61 62 63 3a 3e"
      +   DEBUG - stringtools.stp - STP: data sync (3a) received => changing state STP_STATE_IDLE -> STP_STATE_ESCAPE_1
      +   DEBUG - stringtools.stp - STP: start pattern (3a 3c) received => changing state STP_STATE_ESCAPE_1 -> STP_STATE_STORE_DATA
      +   DEBUG - stringtools.stp - STP: data sync (3a) received => changing state STP_STATE_STORE_DATA -> STP_STATE_ESCAPE_2
      +   DEBUG - stringtools.stp - STP: end pattern (3a 3e) received => storing message and changing state STP_STATE_ESCAPE_2 -> STP_STATE_IDLE
      +    INFO - stringtools.stp - STP: message identified - (3): 61 62 63
      +    INFO - tcp_socket.all_others - comm-client: RX  <- "(3): 61 62 63"
      +The Client received: b'abc'
      +
      +
      +
      + +
      +
      +class tcp_socket.tcp_server(host, port, channel_name=None, rx_tx_log_lvl=20)
      +

      Bases: tcp_base

      +

      This class creates a tcp-server for transfering a serial stream of bytes (characters). See also parent tcp_base.

      +
      +
      Parameters:
      +
        +
      • host (str) – The host IP for the TCP socket functionality

      • +
      • port (int) – The port for the TCP socket functionality

      • +
      • channel_name (str) – The name for the logging channel

      • +
      +
      +
      +
      +

      Note

      +

      You need a tcp_client to communicate with the server.

      +
      +

      Example:

      +
      import sys                  # nopep8
      +sys.path.append('../..')    # nopep8
      +import time
      +import tcp_socket
      +import report
      +
      +
      +def mirror_callback(tcp):
      +    tcp.send(tcp.receive())
      +
      +
      +report.default_logging_config()
      +
      +# Start the server
      +s = tcp_socket.tcp_server('127.0.0.1', 17000)
      +s.register_callback(mirror_callback)
      +
      +# Start the clien
      +c = tcp_socket.tcp_client('127.0.0.1', 17000)
      +c.send(b'abc')
      +print('The Client received: %s' % repr(c.receive()))
      +
      +
      +
         DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +    INFO - tcp_socket.all_others - comm-server: Server listening to 127.0.0.1:17000
      +    INFO - tcp_socket.all_others - comm-server: Connection established... (from 127.0.0.1:17000)
      +    INFO - tcp_socket.all_others - comm-client: Connection established... (to 127.0.0.1:17000)
      +   DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +    INFO - tcp_socket.all_others - comm-client: TX -> "(3): 61 62 63"
      +    INFO - tcp_socket.all_others - comm-server: RX <- "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +    INFO - tcp_socket.all_others - comm-server: TX -> "(3): 61 62 63"
      +    INFO - tcp_socket.all_others - comm-client: RX <- "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +The Client received: b'abc'
      +
      +
      +
      + +
      +
      +class tcp_socket.tcp_server_stp(host, port, channel_name=None)
      +

      Bases: tcp_server, tcp_base_stp

      +

      This class creates a tcp-server for transfering a message. The bytes will be packed on send and unpacked on receive. See also parents tcp_server and tcp_base_stp. +See stringtools.stp for more information on packing and unpacking.

      +
      +
      Parameters:
      +
        +
      • host (str) – The host IP for the TCP socket functionality

      • +
      • port (int) – The port for the TCP socket functionality

      • +
      • channel_name (str) – The name for the logging channel

      • +
      +
      +
      +
      +

      Note

      +

      You need a tcp_client_stp to communicate with the server.

      +
      +

      Example:

      +
      import sys                  # nopep8
      +sys.path.append('../..')    # nopep8
      +
      +import tcp_socket
      +import report
      +
      +
      +def mirror_callback(tcp):
      +    tcp.send(tcp.receive())
      +
      +
      +logger = report.default_logging_config()
      +
      +# Start the server
      +s = tcp_socket.tcp_server_stp('127.0.0.1', 17017)
      +s.register_callback(mirror_callback)
      +
      +# Start the client
      +c = tcp_socket.tcp_client_stp('127.0.0.1', 17017)
      +c.send(b'abc')
      +print('The Client received: %s' % repr(c.receive()))
      +
      +
      +
         DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +    INFO - tcp_socket.all_others - comm-server: Server listening to 127.0.0.1:17017
      +    INFO - tcp_socket.all_others - comm-client: Connection established... (to 127.0.0.1:17017)
      +    INFO - tcp_socket.all_others - comm-server: Connection established... (from 127.0.0.1:17017)
      +   DEBUG - tcp_socket.all_others - comm-client: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-server: Cleaning up receive-buffer
      +   DEBUG - tcp_socket.all_others - comm-client: TX -> "(7): 3a 3c 61 62 63 3a 3e"
      +    INFO - tcp_socket.all_others - comm-client: TX -> "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-server: RX <- "(7): 3a 3c 61 62 63 3a 3e"
      +   DEBUG - stringtools.stp - STP: data sync (3a) received => changing state STP_STATE_IDLE -> STP_STATE_ESCAPE_1
      +   DEBUG - stringtools.stp - STP: start pattern (3a 3c) received => changing state STP_STATE_ESCAPE_1 -> STP_STATE_STORE_DATA
      +   DEBUG - stringtools.stp - STP: data sync (3a) received => changing state STP_STATE_STORE_DATA -> STP_STATE_ESCAPE_2
      +   DEBUG - stringtools.stp - STP: end pattern (3a 3e) received => storing message and changing state STP_STATE_ESCAPE_2 -> STP_STATE_IDLE
      +    INFO - stringtools.stp - STP: message identified - (3): 61 62 63
      +    INFO - tcp_socket.all_others - comm-server: RX  <- "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-server: TX -> "(7): 3a 3c 61 62 63 3a 3e"
      +    INFO - tcp_socket.all_others - comm-server: TX -> "(3): 61 62 63"
      +   DEBUG - tcp_socket.all_others - comm-client: RX <- "(7): 3a 3c 61 62 63 3a 3e"
      +   DEBUG - stringtools.stp - STP: data sync (3a) received => changing state STP_STATE_IDLE -> STP_STATE_ESCAPE_1
      +   DEBUG - stringtools.stp - STP: start pattern (3a 3c) received => changing state STP_STATE_ESCAPE_1 -> STP_STATE_STORE_DATA
      +   DEBUG - stringtools.stp - STP: data sync (3a) received => changing state STP_STATE_STORE_DATA -> STP_STATE_ESCAPE_2
      +   DEBUG - stringtools.stp - STP: end pattern (3a 3e) received => storing message and changing state STP_STATE_ESCAPE_2 -> STP_STATE_IDLE
      +    INFO - stringtools.stp - STP: message identified - (3): 61 62 63
      +    INFO - tcp_socket.all_others - comm-client: RX  <- "(3): 61 62 63"
      +The Client received: b'abc'
      +
      +
      +
      +
      @@ -137,6 +694,45 @@