This isn't strictly Telnet-compatible: I don't see any IAC-command support (i.e. replying WONT or DONT to DO or WILL negotiations), or even handling of "\r\0" (which the RFC defines as the proper serialization of a lone "\r"). It just accepts commands delimited by newlines. Telnet is more than newline-delimited commands!