Putty and telnet newline

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
mattykins
Posts: 203
Joined: Sun Jan 15, 2012 10:15 pm

Putty and telnet newline

Post by mattykins »

So i'm writing a basic telnet server which aims to emulate an IRC like chatroom. It works flawlessly on Linux terminals such as gnome and xterm, but when you try to connect through the common windows telnet client, Putty, it kind of breaks the room. It sends a blank message at the end of 80% of the lines in putty. So if i set my nick to "Matt" and tried to type "Hello" all of the other clients would recieve:
Matt: Hello
Matt:

I've tried catching the blank message and stopping it from sending to every client about 100 different ways but i cant seem to do it, I tried catching:
"\n", "^M", "<CR>", "^[[M", "\^[[M", "\[[M", "\n\r", " ", and a lot more unconventional ways.

The strings I listed above are all of the conventional ways I imagined putty could send a blank/new line. However none of them solve the problem. Its beginnning to become a real headache because I can't start on my MUD until I fix this pretty major glitch, because if someone tries to enter the command , say look. It will send the contents of the room you are in but it will also send an "Invalid command" style thing because putty also sent a blank/empty line after the command.

I thought it was pretty funny though when I SSH'd to my VPS on putty and then telnetted to the server, it worked fine and it was still basically through putty haha. So it is a glitch with the way putty sends newlines i think.

Here is the source code for it, again it works flawlessly on gnome/xterm terminals: http://codepad.org/PzjGAMbU
It is written in Python 2.7.2
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Putty and telnet newline

Post by Jackolantern »

I can't help much with the code, but have you tried other Windows telnet clients? Putty is not the official Windows telnet client, and thus, introduces potential bugs and incompatibilities of its own. Trying another telnet client could determine whether it is an issue in the client, or if the problem lies in the platform.
The indelible lord of tl;dr
User avatar
mattykins
Posts: 203
Joined: Sun Jan 15, 2012 10:15 pm

Re: Putty and telnet newline

Post by mattykins »

I've tried the telnet client that comes with windows, and putty. Most windows users who actively use ssh and telnet protocals use putty so I figured that would be a main one to have compatibility for. And seeing how the code i linked runs fine on linux machines it doesn't make sense to me why putty would break it.

EDIT: The windows telnet client breaks it as well.
Winawer
Posts: 180
Joined: Wed Aug 17, 2011 5:53 am

Re: Putty and telnet newline

Post by Winawer »

mattykins wrote:I tried catching:
..."\n\r"...
You mean "\r\n"?

Maybe something like

Code: Select all

message = message.replace('\r\n', '\n').replace('\r', '\n')
would work?
Post Reply

Return to “Beginner Help and Support”