Odd Behavior when Connecting to my Program

2019-02-23 12:48发布

问题:

I'm using Twisted to implement a server, of sorts. When I test it, the first line it receives is always strange:

Starting Server...
New connection from  192.168.1.140
192.168.1.140: ÿûÿû ÿûÿû'ÿýÿûÿý\NAME Blurr
192.168.1.140: \NAME Blurr

(for both inputs I sent \NAME Blurr.)

This is the code that prints the input:

def lineReceived(self, line):
    print "{0}: {1}".format(self.name, line)

I'm connecting via Putty through Telnet to a remote host. Is this a telnet protocol I'm missing, or what? When I use Unix's telnet program and connect locally, the first line is fine.

回答1:

You can find an explanation of the "ÿûÿû mystery" here. Short form: telnet is not a simple protocol, and what you're seeing is a trace of a telnet negotiation (trying to) occur with a server that doesn't speak "telnettese";-). Good guess about "is this a telnet protocol I'm missing";-)

The RFCs involved in defining the telnet protocol are linked from this page, if you want to debug further. I'm no putty expert so I don't know how to tell putty to avoid this negotiation (and act like the good old simple Unix telnet client;-).



回答2:

It was indeed a telnet protocol I was missing. Connecting as Raw instead Telnet solved the problem.