Python socket client request echo
<p>I am testing communication with a socket server using a simple script built with Python's select module. It works fine - I get responses from the server - except that <em>any request I send seems to be echoed in the first line of the response</em> (see command line example below). The server provider says this isn't him echoing the request - what am I failing to do when sending the request ? (flushing some buffer somewhere ?)</p>

<hr>

<p>select_client.py</p>

<pre><code>Prompt="&gt;&gt;&gt;"

def loop(chan, bufsize):
    while True:
        r, w, e = select.select([chan, sys.stdin], [], [])
        if chan in r:
            data=chan.recv(bufsize)
            if len(data)==0:
                continue
            sys.stdout.write(data)
            sys.stdout.write("%s " % Prompt)
            sys.stdout.flush()
        if sys.stdin in r:
            data=sys.stdin.readline()
            if data=="\n":
                break
            chan.send(data)
</code></pre>

<hr>

<p>sample usage </p>

<pre><code>&gt;&gt;&gt; hello
hello &lt;--------- ECHO!
error:no_version_specified
&gt;&gt;&gt; login:1
login:1 &lt;---------- ...!
error:usage:login:1:username?:passwd?
&gt;&gt;&gt; login:1:foo:bar
login:1:foo:bar
&gt;&gt;&gt; error:incorrect_username_or_password
&gt;&gt;&gt; 
</code></pre>
