123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696 |
-
-
- <!DOCTYPE html>
- <html class="writer-html4" lang="en" >
- <head>
- <meta charset="utf-8">
-
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
-
- <title>Welcome to tcp_socket’s documentation! — tcp_socket documentation</title>
-
-
-
- <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
- <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
-
-
-
-
-
-
-
- <!--[if lt IE 9]>
- <script src="_static/js/html5shiv.min.js"></script>
- <![endif]-->
-
-
- <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
- <script type="text/javascript" src="_static/jquery.js"></script>
- <script type="text/javascript" src="_static/underscore.js"></script>
- <script type="text/javascript" src="_static/doctools.js"></script>
- <script type="text/javascript" src="_static/language_data.js"></script>
-
- <script type="text/javascript" src="_static/js/theme.js"></script>
-
-
- <link rel="index" title="Index" href="genindex.html" />
- <link rel="search" title="Search" href="search.html" />
- </head>
-
- <body class="wy-body-for-nav">
-
-
- <div class="wy-grid-for-nav">
-
- <nav data-toggle="wy-nav-shift" class="wy-nav-side">
- <div class="wy-side-scroll">
- <div class="wy-side-nav-search" >
-
-
-
- <a href="#" class="icon icon-home" alt="Documentation Home"> tcp_socket
-
-
-
- </a>
-
-
-
-
-
-
-
- <div role="search">
- <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
- <input type="text" name="q" placeholder="Search docs" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
-
-
- </div>
-
-
- <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
-
-
-
-
-
-
- <!-- Local TOC -->
- <div class="local-toc"><ul>
- <li><a class="reference internal" href="#">Welcome to tcp_socket’s documentation!</a><ul>
- <li><a class="reference internal" href="#tcp-socket-tcp-socket">tcp_socket (TCP Socket)</a></li>
- </ul>
- </li>
- <li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
- </ul>
- </div>
-
-
- </div>
-
- </div>
- </nav>
-
- <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
-
-
- <nav class="wy-nav-top" aria-label="top navigation">
-
- <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
- <a href="#">tcp_socket</a>
-
- </nav>
-
-
- <div class="wy-nav-content">
-
- <div class="rst-content">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <div role="navigation" aria-label="breadcrumbs navigation">
-
- <ul class="wy-breadcrumbs">
-
- <li><a href="#" class="icon icon-home"></a> »</li>
-
- <li>Welcome to tcp_socket’s documentation!</li>
-
-
- <li class="wy-breadcrumbs-aside">
-
-
- <a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
-
-
- </li>
-
- </ul>
-
-
- <hr/>
- </div>
- <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
- <div itemprop="articleBody">
-
- <div class="section" id="module-tcp_socket">
- <span id="welcome-to-tcp-socket-s-documentation"></span><h1>Welcome to tcp_socket’s documentation!<a class="headerlink" href="#module-tcp_socket" title="Permalink to this headline">¶</a></h1>
- <div class="section" id="tcp-socket-tcp-socket">
- <h2>tcp_socket (TCP Socket)<a class="headerlink" href="#tcp-socket-tcp-socket" title="Permalink to this headline">¶</a></h2>
- <p><strong>Author:</strong></p>
- <ul class="simple">
- <li>Dirk Alders <<a class="reference external" href="mailto:sudo-dirk%40mount-mockery.de">sudo-dirk<span>@</span>mount-mockery<span>.</span>de</a>></li>
- </ul>
- <p><strong>Description:</strong></p>
- <blockquote>
- <div>This Module supports a client/ server tcp socket connection.</div></blockquote>
- <p><strong>Submodules:</strong></p>
- <ul class="simple">
- <li><a class="reference internal" href="#tcp_socket.tcp_client" title="tcp_socket.tcp_client"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_socket.tcp_client</span></code></a></li>
- <li><a class="reference internal" href="#tcp_socket.tcp_client_stp" title="tcp_socket.tcp_client_stp"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_socket.tcp_client_stp</span></code></a></li>
- <li><a class="reference internal" href="#tcp_socket.tcp_server" title="tcp_socket.tcp_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_socket.tcp_server</span></code></a></li>
- <li><a class="reference internal" href="#tcp_socket.tcp_server_stp" title="tcp_socket.tcp_server_stp"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_socket.tcp_server_stp</span></code></a></li>
- </ul>
- <p><strong>Unittest:</strong></p>
- <blockquote>
- <div>See also the <a class="reference download internal" download="" href="_downloads/e4086ba3197d1869e430d0a75a9a48e9/unittest.pdf"><code class="xref download docutils literal notranslate"><span class="pre">unittest</span></code></a> documentation.</div></blockquote>
- <p><strong>Module Documentation:</strong></p>
- <dl class="class">
- <dt id="tcp_socket.tcp_base">
- <em class="property">class </em><code class="descclassname">tcp_socket.</code><code class="descname">tcp_base</code><span class="sig-paren">(</span><em>host</em>, <em>port</em>, <em>channel_name=None</em>, <em>rx_tx_log_lvl=20</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base" title="Permalink to this definition">¶</a></dt>
- <dd><p>This is the base class for other classes in this module.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>host</strong> (<em>str</em>) – The host IP for the TCP socket functionality</li>
- <li><strong>port</strong> (<em>int</em>) – The port for the TCP socket functionality</li>
- <li><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">This class is not designed for direct usage.</p>
- </div>
- <dl class="method">
- <dt id="tcp_socket.tcp_base.client_address">
- <code class="descname">client_address</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.client_address" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method returns the address of the connected client.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The client address.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base.close">
- <code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.close" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method closes the connected communication channel, if exists.</p>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base.init_channel_name">
- <code class="descname">init_channel_name</code><span class="sig-paren">(</span><em>channel_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.init_channel_name" title="Permalink to this definition">¶</a></dt>
- <dd><p>With this Method, the channel name for logging can be changed.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base.is_connected">
- <code class="descname">is_connected</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.is_connected" title="Permalink to this definition">¶</a></dt>
- <dd><p>With this Method the connection status can be identified.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True, if a connection is established, otherwise False.</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base.receive">
- <code class="descname">receive</code><span class="sig-paren">(</span><em>timeout=1</em>, <em>num=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.receive" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method returns received data.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>timeout</strong> (<em>float</em>) – The timeout for receiving data (at least after the timeout the method returns data or None).</li>
- <li><strong>num</strong> (<em>int</em>) – the number of bytes to receive (use None to get all available data).</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The received data.</p>
- </td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bytes</p>
- </td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base.register_callback">
- <code class="descname">register_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.register_callback" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method stores the callback which is executed, if data is available. You need to execute <a class="reference internal" href="#tcp_socket.tcp_base.receive" title="tcp_socket.tcp_base.receive"><code class="xref py py-func docutils literal notranslate"><span class="pre">receive()</span></code></a> of this instance
- given as first argument.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, when data is available.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base.register_connect_callback">
- <code class="descname">register_connect_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.register_connect_callback" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method stores the callback which is executed, if a connection is established.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, when a connection is established.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base.register_disconnect_callback">
- <code class="descname">register_disconnect_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.register_disconnect_callback" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method stores the callback which is executed, after the connection is lost.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, after the connection is lost.</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base.send">
- <code class="descname">send</code><span class="sig-paren">(</span><em>data</em>, <em>timeout=1</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base.send" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method sends data via the initiated communication channel.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>data</strong> (<em>bytes</em>) – The data to be send over the communication channel.</li>
- <li><strong>timeout</strong> (<em>float</em>) – The timeout for sending data (e.g. time to establish new connection).</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True if data had been sent, otherwise False.</p>
- </td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
- </td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- </dd></dl>
-
- <dl class="class">
- <dt id="tcp_socket.tcp_base_stp">
- <em class="property">class </em><code class="descclassname">tcp_socket.</code><code class="descname">tcp_base_stp</code><span class="sig-paren">(</span><em>host</em>, <em>port</em>, <em>channel_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base_stp" title="Permalink to this definition">¶</a></dt>
- <dd><p>This is the base class for other classes in this module. See also parent <a class="reference internal" href="#tcp_socket.tcp_base" title="tcp_socket.tcp_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_base</span></code></a>.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>host</strong> (<em>str</em>) – The host IP for the TCP socket functionality</li>
- <li><strong>port</strong> (<em>int</em>) – The port for the TCP socket functionality</li>
- <li><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">This class is not designed for direct usage.</p>
- </div>
- <dl class="method">
- <dt id="tcp_socket.tcp_base_stp.receive">
- <code class="descname">receive</code><span class="sig-paren">(</span><em>timeout=1</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base_stp.receive" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method returns one received messages via the initiated communication channel.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>timeout</strong> (<em>float</em>) – The timeout for receiving data (at least after the timeout the method returns data or None).</td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The received data.</td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">bytes</td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- <dl class="method">
- <dt id="tcp_socket.tcp_base_stp.send">
- <code class="descname">send</code><span class="sig-paren">(</span><em>data</em>, <em>timeout=1</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_base_stp.send" title="Permalink to this definition">¶</a></dt>
- <dd><p>This method sends one stp message via the initiated communication channel.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
- <li><strong>data</strong> (<em>bytes</em>) – The message to be send over the communication channel.</li>
- <li><strong>timeout</strong> (<em>float</em>) – The timeout for sending data (e.g. time to establish new connection).</li>
- </ul>
- </td>
- </tr>
- <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True if data had been sent, otherwise False.</p>
- </td>
- </tr>
- <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
- </td>
- </tr>
- </tbody>
- </table>
- </dd></dl>
-
- </dd></dl>
-
- <dl class="class">
- <dt id="tcp_socket.tcp_client">
- <em class="property">class </em><code class="descclassname">tcp_socket.</code><code class="descname">tcp_client</code><span class="sig-paren">(</span><em>host</em>, <em>port</em>, <em>channel_name=None</em>, <em>rx_tx_log_lvl=20</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_client" title="Permalink to this definition">¶</a></dt>
- <dd><p>This class creates a tcp-client for transfering a serial stream of bytes (characters). See also parent <a class="reference internal" href="#tcp_socket.tcp_base" title="tcp_socket.tcp_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_base</span></code></a>.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>host</strong> (<em>str</em>) – The host IP for the TCP socket functionality</li>
- <li><strong>port</strong> (<em>int</em>) – The port for the TCP socket functionality</li>
- <li><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">You need a running <a class="reference internal" href="#tcp_socket.tcp_server" title="tcp_socket.tcp_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_server</span></code></a> listening at the given IP and Port to be able to communicate.</p>
- </div>
- <p><strong>Example:</strong></p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
- <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
-
- <span class="kn">import</span> <span class="nn">report</span>
- <span class="kn">import</span> <span class="nn">tcp_socket</span>
- <span class="kn">import</span> <span class="nn">time</span>
-
-
- <span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
- <span class="k">return</span> <span class="n">data</span>
-
-
- <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">'root'</span><span class="p">,</span> <span class="s1">'DEBUG'</span><span class="p">),</span> <span class="p">])</span>
- <span class="n">c</span> <span class="o">=</span> <span class="n">tcp_socket</span><span class="o">.</span><span class="n">tcp_client</span><span class="p">(</span><span class="s1">'127.0.0.1'</span><span class="p">,</span> <span class="mi">17000</span><span class="p">)</span>
- <span class="n">c</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="sa">b</span><span class="s1">'abc'</span><span class="p">)</span>
- <span class="nb">print</span><span class="p">(</span><span class="s1">'The Client received: </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="nb">repr</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">receive</span><span class="p">()))</span>
- </pre></div>
- </div>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">183</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">233</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span> <span class="p">(</span><span class="n">to</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">17000</span><span class="p">)</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">234</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">283</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="s2">"(3): 61 62 63"</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">284</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="s2">"(3): 61 62 63"</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">334</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="n">The</span> <span class="n">Client</span> <span class="n">received</span><span class="p">:</span> <span class="sa">b</span><span class="s1">'abc'</span>
- </pre></div>
- </div>
- </dd></dl>
-
- <dl class="class">
- <dt id="tcp_socket.tcp_client_stp">
- <em class="property">class </em><code class="descclassname">tcp_socket.</code><code class="descname">tcp_client_stp</code><span class="sig-paren">(</span><em>host</em>, <em>port</em>, <em>channel_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_client_stp" title="Permalink to this definition">¶</a></dt>
- <dd><p>This class creates a tcp-client for transfering a message. The bytes will be packed on send and unpacked on receive. See also parents <a class="reference internal" href="#tcp_socket.tcp_client" title="tcp_socket.tcp_client"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_client</span></code></a> and <a class="reference internal" href="#tcp_socket.tcp_base_stp" title="tcp_socket.tcp_base_stp"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_base_stp</span></code></a>.
- See <code class="xref py py-mod docutils literal notranslate"><span class="pre">stringtools.stp</span></code> for more information on packing and unpacking.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>host</strong> (<em>str</em>) – The host IP for the TCP socket functionality</li>
- <li><strong>port</strong> (<em>int</em>) – The port for the TCP socket functionality</li>
- <li><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">You need a running <a class="reference internal" href="#tcp_socket.tcp_server_stp" title="tcp_socket.tcp_server_stp"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_server_stp</span></code></a> listening at the given IP and Port to be able to communicate.</p>
- </div>
- <p><strong>Example:</strong></p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
- <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
-
- <span class="kn">import</span> <span class="nn">report</span>
- <span class="kn">import</span> <span class="nn">tcp_socket</span>
- <span class="kn">import</span> <span class="nn">time</span>
-
-
- <span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
- <span class="k">return</span> <span class="n">data</span>
-
-
- <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">'root'</span><span class="p">,</span> <span class="s1">'DEBUG'</span><span class="p">),</span> <span class="p">])</span>
- <span class="n">c</span> <span class="o">=</span> <span class="n">tcp_socket</span><span class="o">.</span><span class="n">tcp_client_stp</span><span class="p">(</span><span class="s1">'127.0.0.1'</span><span class="p">,</span> <span class="mi">17017</span><span class="p">)</span>
- <span class="n">c</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="sa">b</span><span class="s1">'abc'</span><span class="p">)</span>
- <span class="nb">print</span><span class="p">(</span><span class="s1">'The Client received: </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="nb">repr</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">receive</span><span class="p">()))</span>
- </pre></div>
- </div>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">784</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">839</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span> <span class="p">(</span><span class="n">to</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">17017</span><span class="p">)</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">839</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- </pre></div>
- </div>
- </dd></dl>
-
- <dl class="class">
- <dt id="tcp_socket.tcp_server">
- <em class="property">class </em><code class="descclassname">tcp_socket.</code><code class="descname">tcp_server</code><span class="sig-paren">(</span><em>host</em>, <em>port</em>, <em>channel_name=None</em>, <em>rx_tx_log_lvl=20</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_server" title="Permalink to this definition">¶</a></dt>
- <dd><p>This class creates a tcp-server for transfering a serial stream of bytes (characters). See also parent <a class="reference internal" href="#tcp_socket.tcp_base" title="tcp_socket.tcp_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_base</span></code></a>.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>host</strong> (<em>str</em>) – The host IP for the TCP socket functionality</li>
- <li><strong>port</strong> (<em>int</em>) – The port for the TCP socket functionality</li>
- <li><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">You need a <a class="reference internal" href="#tcp_socket.tcp_client" title="tcp_socket.tcp_client"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_client</span></code></a> to communicate with the server.</p>
- </div>
- <p><strong>Example:</strong></p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
- <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
-
- <span class="kn">import</span> <span class="nn">report</span>
- <span class="kn">import</span> <span class="nn">tcp_socket</span>
- <span class="kn">import</span> <span class="nn">time</span>
-
- <span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">tcp</span><span class="p">):</span>
- <span class="n">tcp</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">tcp</span><span class="o">.</span><span class="n">receive</span><span class="p">())</span>
-
-
- <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">'root'</span><span class="p">,</span> <span class="s1">'DEBUG'</span><span class="p">),</span> <span class="p">])</span>
- <span class="n">s</span> <span class="o">=</span> <span class="n">tcp_socket</span><span class="o">.</span><span class="n">tcp_server</span><span class="p">(</span><span class="s1">'127.0.0.1'</span><span class="p">,</span> <span class="mi">17000</span><span class="p">)</span>
- <span class="n">s</span><span class="o">.</span><span class="n">register_callback</span><span class="p">(</span><span class="n">mirror_callback</span><span class="p">)</span>
-
- <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
- <span class="k">while</span> <span class="ow">not</span> <span class="n">s</span><span class="o">.</span><span class="n">is_connected</span><span class="p">()</span> <span class="ow">and</span> <span class="n">i</span> <span class="o"><=</span> <span class="mi">10</span><span class="p">:</span>
- <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
- <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="o">.</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># wait for a connection</span>
-
- <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
- <span class="k">while</span> <span class="n">s</span><span class="o">.</span><span class="n">is_connected</span><span class="p">()</span> <span class="ow">and</span> <span class="n">i</span> <span class="o"><=</span> <span class="mi">10</span><span class="p">:</span>
- <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
- <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="o">.</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># wait for disconnect</span>
- </pre></div>
- </div>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">392</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">392</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Server</span> <span class="n">listening</span> <span class="n">to</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">17000</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">544</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span> <span class="p">(</span><span class="kn">from</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">17000</span><span class="p">)</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">544</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">594</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="s2">"(3): 61 62 63"</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">595</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">595</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="s2">"(3): 61 62 63"</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">747</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">lost</span><span class="o">...</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">15</span><span class="p">:</span><span class="mi">57</span><span class="p">,</span><span class="mi">748</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Server</span> <span class="n">listening</span> <span class="n">to</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">17000</span>
- </pre></div>
- </div>
- </dd></dl>
-
- <dl class="class">
- <dt id="tcp_socket.tcp_server_stp">
- <em class="property">class </em><code class="descclassname">tcp_socket.</code><code class="descname">tcp_server_stp</code><span class="sig-paren">(</span><em>host</em>, <em>port</em>, <em>channel_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#tcp_socket.tcp_server_stp" title="Permalink to this definition">¶</a></dt>
- <dd><p>This class creates a tcp-server for transfering a message. The bytes will be packed on send and unpacked on receive. See also parents <a class="reference internal" href="#tcp_socket.tcp_server" title="tcp_socket.tcp_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_server</span></code></a> and <a class="reference internal" href="#tcp_socket.tcp_base_stp" title="tcp_socket.tcp_base_stp"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_base_stp</span></code></a>.
- See <code class="xref py py-mod docutils literal notranslate"><span class="pre">stringtools.stp</span></code> for more information on packing and unpacking.</p>
- <table class="docutils field-list" frame="void" rules="none">
- <col class="field-name" />
- <col class="field-body" />
- <tbody valign="top">
- <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
- <li><strong>host</strong> (<em>str</em>) – The host IP for the TCP socket functionality</li>
- <li><strong>port</strong> (<em>int</em>) – The port for the TCP socket functionality</li>
- <li><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</li>
- </ul>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="admonition note">
- <p class="first admonition-title">Note</p>
- <p class="last">You need a <a class="reference internal" href="#tcp_socket.tcp_client_stp" title="tcp_socket.tcp_client_stp"><code class="xref py py-class docutils literal notranslate"><span class="pre">tcp_client_stp</span></code></a> to communicate with the server.</p>
- </div>
- <p><strong>Example:</strong></p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
- <span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">'../..'</span><span class="p">)</span>
-
- <span class="kn">import</span> <span class="nn">report</span>
- <span class="kn">import</span> <span class="nn">tcp_socket</span>
- <span class="kn">import</span> <span class="nn">time</span>
-
- <span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">tcp</span><span class="p">):</span>
- <span class="n">tcp</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">tcp</span><span class="o">.</span><span class="n">receive</span><span class="p">())</span>
-
-
- <span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">'root'</span><span class="p">,</span> <span class="s1">'DEBUG'</span><span class="p">),</span> <span class="p">])</span>
- <span class="n">s</span> <span class="o">=</span> <span class="n">tcp_socket</span><span class="o">.</span><span class="n">tcp_server_stp</span><span class="p">(</span><span class="s1">'127.0.0.1'</span><span class="p">,</span> <span class="mi">17017</span><span class="p">)</span>
- <span class="n">s</span><span class="o">.</span><span class="n">register_callback</span><span class="p">(</span><span class="n">mirror_callback</span><span class="p">)</span>
-
- <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
- <span class="k">while</span> <span class="ow">not</span> <span class="n">s</span><span class="o">.</span><span class="n">is_connected</span><span class="p">()</span> <span class="ow">and</span> <span class="n">i</span> <span class="o"><=</span> <span class="mi">10</span><span class="p">:</span>
- <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
- <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="o">.</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># wait for a connection</span>
-
- <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
- <span class="k">while</span> <span class="n">s</span><span class="o">.</span><span class="n">is_connected</span><span class="p">()</span> <span class="ow">and</span> <span class="n">i</span> <span class="o"><=</span> <span class="mi">10</span><span class="p">:</span>
- <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
- <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="o">.</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># wait for disconnect</span>
- </pre></div>
- </div>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">425</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">425</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Server</span> <span class="n">listening</span> <span class="n">to</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">17017</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">526</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span> <span class="p">(</span><span class="kn">from</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">17017</span><span class="p">)</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">526</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">up</span> <span class="n">receive</span><span class="o">-</span><span class="n">buffer</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">627</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="s2">"(7): 3a 3c 61 62 63 3a 3e"</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">627</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">data</span> <span class="n">sync</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span><span class="p">)</span> <span class="n">received</span> <span class="o">=></span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_IDLE</span> <span class="o">-></span> <span class="n">STP_STATE_ESCAPE_1</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">628</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">start</span> <span class="n">pattern</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span> <span class="mi">3</span><span class="n">c</span><span class="p">)</span> <span class="n">received</span> <span class="o">=></span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_ESCAPE_1</span> <span class="o">-></span> <span class="n">STP_STATE_STORE_DATA</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">628</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">data</span> <span class="n">sync</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span><span class="p">)</span> <span class="n">received</span> <span class="o">=></span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_STORE_DATA</span> <span class="o">-></span> <span class="n">STP_STATE_ESCAPE_2</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">628</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">end</span> <span class="n">pattern</span> <span class="p">(</span><span class="mi">3</span><span class="n">a</span> <span class="mi">3</span><span class="n">e</span><span class="p">)</span> <span class="n">received</span> <span class="o">=></span> <span class="n">storing</span> <span class="n">message</span> <span class="ow">and</span> <span class="n">changing</span> <span class="n">state</span> <span class="n">STP_STATE_ESCAPE_2</span> <span class="o">-></span> <span class="n">STP_STATE_IDLE</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">628</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">stringtools</span><span class="o">.</span><span class="n">stp</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">STP</span><span class="p">:</span> <span class="n">message</span> <span class="n">identified</span> <span class="o">-</span> <span class="p">(</span><span class="mi">3</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span> <span class="mi">63</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">628</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">RX</span> <span class="o"><-</span> <span class="s2">"(3): 61 62 63"</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">628</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="s2">"(7): 3a 3c 61 62 63 3a 3e"</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">629</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-></span> <span class="s2">"(3): 61 62 63"</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">780</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">lost</span><span class="o">...</span>
- <span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">11</span> <span class="mi">07</span><span class="p">:</span><span class="mi">17</span><span class="p">:</span><span class="mi">54</span><span class="p">,</span><span class="mi">780</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">tcp_socket</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">comm</span><span class="o">-</span><span class="n">server</span><span class="p">:</span> <span class="n">Server</span> <span class="n">listening</span> <span class="n">to</span> <span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span><span class="p">:</span><span class="mi">17017</span>
- </pre></div>
- </div>
- </dd></dl>
-
- </div>
- <div class="toctree-wrapper compound">
- </div>
- </div>
- <div class="section" id="indices-and-tables">
- <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">¶</a></h1>
- <ul class="simple">
- <li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
- <li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
- <li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
- </ul>
- </div>
-
-
- </div>
-
- </div>
- <footer>
-
-
- <hr/>
-
- <div role="contentinfo">
- <p>
-
- © Copyright 2021, Dirk Alders
-
- </p>
- </div>
-
-
-
- Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
-
- <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
-
- provided by <a href="https://readthedocs.org">Read the Docs</a>.
-
- </footer>
-
- </div>
- </div>
-
- </section>
-
- </div>
-
-
- <script type="text/javascript">
- jQuery(function () {
- SphinxRtdTheme.Navigation.enable(true);
- });
- </script>
-
-
-
-
-
-
- </body>
- </html>
|