Peter,<br><br>Thanks for the assistance.  I think you and David have me on the right path.  Just to clarify the protocol looks like this:<br><br>Content-Length: 984<br>Content-Type: text/event-xml<br><br>&lt;event&gt;<br>  &lt;headers&gt;<br>
   $bunchofinfo ...<br>  &lt;/headers&gt;<br>&lt;/event&gt;<br><br>Where the body (and the content length) start and stop with the &lt;event&gt; ... &lt;/event&gt;.<br><br>Here is what I&#39;ve done so far:<br><br>from twisted.internet import reactor, protocol<br>
from twisted.protocols import basic<br>from re import compile, findall<br><br>bl_p = compile(&#39;Content-Length:\s(\d+)&#39;)<br><br>class My_Client(basic.LineReceiver):<br>    def __init__(self):<br>        self.body_length = None<br>
 <br>    def connectionMade(self):<br>        self.transport.write(&quot;login \r\n\r\n&quot;)<br>        self.transport.write(&quot;sendevents\r\n\r\n&quot;)<br>    <br>    def lineReceived(self, line):<br>        print line<br>
        bl_m = bl_p.findall(line)<br>        if bl_m:<br>            print &#39;Match:&#39;<br>            self.body_length = int(bl_m[0]) - len(line) # this doesn&#39;t really work because it doesn&#39;t factor in the len of the next line<br>
            self.setRawMode()<br><br>    def rawDataReceived(self, data):<br>       datalen = len(data)<br>       if self.body_length &gt; datalen:<br>           self.body_length -= datalen<br>           print data<br>       else:<br>
           part = data[:self.body_length]<br>           extra = data[self.body_length:]<br>           print &#39;Left Over\n:&#39;<br>           print extra<br>           self.setLineMode(extra=extra)    <br><br>    def connectionLost(self, reason):<br>
        print &quot;%s&quot; % (reason)<br><br>class My_Factory(protocol.ClientFactory):<br>    protocol = My_Client<br><br>    def clientConnectionFailed(self, connector, reason):<br>        print &quot;Connection failed - goodbye!&quot;<br>
        reactor.stop()<br>    <br>    def clientConnectionLost(self, connector, reason):<br>        print &quot;Connection lost - goodbye!&quot;<br>        reactor.stop()<br><br>def main():<br>    f = FS_Factory()<br>    reactor.connectTCP(&quot;$IP&quot;, $PORT, f)<br>
    reactor.run()<br><br># this only runs if the module was *not* imported<br>if __name__ == &#39;__main__&#39;:<br>    main()<br><br>To me ... this looks somewhat correct ... but it doesn&#39;t seem to actually ever use the line received method (note the print statement ...).  For instance upon logging in it should respond with a +OK Logged In ... but it never prints that.<br>
<br>And then when it receives an &quot;&lt;event&gt;...&quot; it actually dies with this error:<br><br>[Failure instance: Traceback (failure with no frames): &lt;class &#39;twisted.internet.error.ConnectionDone&#39;&gt;: Connection was closed cleanly.<br>
]<br>Connection lost - goodbye!<br><br>So I&#39;m a bit lost as to what the impact of adding the rawDataReceived method has done.  <br><br>Thanks!<br><br>SDR<br><br><br><br>