why does text from socket server erase previously written text?

Posted by mix on Stack Overflow See other posts from Stack Overflow or by mix
Published on 2010-06-13T00:40:06Z Indexed on 2010/06/13 0:42 UTC
Read the original article Hit count: 467

Filed under:
|

This is strange enough I'm not sure how to search for an answer. I have a program in Python that communicates via TCP/IP sockets to a telnet-based server. If I telnet in manually and type commands like this:

SET MDI G0 X0 Y0

the server will spit back a line like this:

SET MDI ACK

Pretty standard stuff. Here's the weird part. If, in my code, I precede my printing of each of these lines with some text, the returned line erases what I'm trying to print before it. So for example, if I write the code so it should look like this:

SENT: SET MDI G0 X0 Y0
READ: SET MDI ACK

What I get instead is:

SENT: SET MDI G0 X0 Y0
SET MDI ACK

Now, if I make the "READ: " text a bit longer, I can get a better idea of what's happening. Let's say I change READ: to 12345678901234567890, so that it should read as:

12345678901234567890: SET MDI ACK

What I get instead is:

SET MDI ACK234567890:

So it seems like whatever text I'm getting back from the server is somehow deleting what I'm trying to precede it with. I tried saving all of my saved lines in a list, and then printing them out at the end, but it does exactly the same thing.

Any ideas on what's going on, or even on how to debug this? Is there a way to get Python to show me any hidden chars in a string, for example?

thx!

© Stack Overflow or respective owner

Related posts about python

Related posts about sockets