<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Here is the server code:<div><div>-------------</div><div><div>from twisted.internet.protocol import Protocol, Factory</div><div>from twisted.internet import reactor</div><div>import sys</div><div><br class="webkit-block-placeholder"></div><div>class MyServer(Protocol):</div><div>    def connectionMade(self):<br></div><div>        self.transport.write("Hello")</div><div><br class="webkit-block-placeholder"></div><div>factory = Factory()</div><div>factory.protocol =  MyServer</div><div><br class="webkit-block-placeholder"></div><div>reactor.listenTCP(2000, factory)<br></div><div>reactor.run()</div><div>-----------</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div>Here is the client code:</div><div>--------------</div><div><div>from twisted.internet.protocol import Protocol,
 ClientCreator</div><div>from twisted.internet import reactor</div><div>import sys</div><div><br class="webkit-block-placeholder"></div><div>class MyClient(Protocol):</div><div>    def dataReceived(self, data):</div><div>        sys.stdout.write(data)</div><div>        self.transport.loseConnection()</div><div>------------</div><div><br class="webkit-block-placeholder"></div><div>What do I need to add to the client code to make it connect to the server?  I think the "How To" documentation is woefully inadequate.  For instance, it says this:</div><div><br class="webkit-block-placeholder"></div><div>----</div><div><span class="Apple-style-span" style="font-family: Helvetica; font-size: 16px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Here is a simple example:</p><pre class="python" style="padding-top: 1em; padding-right: 1em; padding-bottom: 1em; padding-left: 1em; border-top-width: thin;
 border-right-width: thin; border-bottom-width: thin; border-left-width: thin; border-top-color: black; border-right-color: black; border-bottom-color: black; border-left-color: black; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; background-color: rgb(221, 221, 221); "><span class="py-src-keyword" style="color: rgb(51, 51, 204); font-weight: bold; ">from</span> <span class="py-src-variable">twisted</span>.<span class="py-src-variable">internet</span>.<span class="py-src-variable">protocol</span> <span class="py-src-keyword" style="color: rgb(51, 51, 204); font-weight: bold; ">import</span> <span class="py-src-variable">Protocol</span>
<span class="py-src-keyword" style="color: rgb(51, 51, 204); font-weight: bold; ">from</span> <span class="py-src-variable">sys</span> <span class="py-src-keyword" style="color: rgb(51, 51, 204); font-weight: bold; ">import</span> <span class="py-src-variable">stdout</span>

<span class="py-src-keyword" style="color: rgb(51, 51, 204); font-weight: bold; ">class</span> <span class="py-src-identifier" style="color: rgb(204, 0, 0); ">Echo</span>(<span class="py-src-parameter" style="color: rgb(0, 0, 102); font-weight: bold; ">Protocol</span>):
    <span class="py-src-keyword" style="color: rgb(51, 51, 204); font-weight: bold; ">def</span> <span class="py-src-identifier" style="color: rgb(204, 0, 0); ">dataReceived</span>(<span class="py-src-parameter" style="color: rgb(0, 0, 102); font-weight: bold; ">self</span>, <span class="py-src-parameter" style="color: rgb(0, 0, 102); font-weight: bold; ">data</span>):
        <span class="py-src-variable">stdout</span>.<span class="py-src-variable">write</span>(<span class="py-src-variable">data)</span></pre></span></div><div>------</div><div><br class="webkit-block-placeholder"></div><div>Anyone who knows even a little bit of python should be able to recognize that that code does absolutely nothing.  </div></div></div></div></td></tr></table><br>