Networking Problems

Jonathan Gardner jgardn at
Tue Feb 12 04:59:00 EST 2002

Simon Crosby wrote:

> Hi
> I have recently tried programming a text network game using sockets in
> python as detailed in "Programming Python" 2nd ed. I developed this on
> linux and used telnet as a client. Then I tried connecting to the game
> server with windows telnet. This showed the text very differently,
> ignoring newlines and when prompting for input takes any character as a
> newline. It does not matter if the server is run on linux or windows.
> Attached is my networking code.

You'll want to use "\012\015" explicitly as a newline. This is both for 
input and output.

Windows telnet sends characters as they are typed. Linux telnet defaults to 
sending whole lines rather than individual characters. The best way is to 
collect input from the client until the client sends "\012\015".

Also, your whole design is lacking. You'll need a server that can 
handle multiple connections. I suggest using non-blocking sockets and 
select. It's better to build the server like this from the beginning 
because it affects how you do everything.


More information about the Python-list mailing list