TAEB::Interface::Telnet - how TAEB talks to nethack.alt.org
read -> STRING
This will read from the socket. It will die if an error occurs.
It will return the input read from the socket.
This uses a method developed for nhbot that ensures that we've received all output for our command before returning. Just before reading, it sends the telnet equivalent of a PING. It then reads all input until it gets a PONG. the idea is that the PING comes after all NH commands, so the PONG must come after all the output of all the NH commands. The code looking for the PONG is in the telnet complex callback.
The actual ping it uses is to send IAC DO chr(99), which is a nonexistent option. Some servers may stop responding after the first IAC DO chr(99), so it's kind of a bad hack. It used to be IAC SB STATUS SEND IAC SE but NAO stopped paying attention to that. That last sentence was discovered over a few hours of debugging. Yay.
This will write to the socket.
This is a helper function used in conjunction with IO::Socket::Telnet. In short, all nethack.alt.org expects us to answer affirmatively is TTYPE (to which we respond xterm-color) and NAWS (to which we respond 80x24). Everything else gets a response of DONT or WONT.