I'm borrowing a short C code that establishes a telnet session using a child-parent scheme and handles the communication between both processes through a pseudo terminal device.
The code runs pretty fine but with one major flaw, the telnet process doesn't execute most escape sequences, printing them instead (ESC prints ^[[, arrows ^[[A ^[[B ^[[C ^[[D, etc.).
I've already done quite a bit of research now but I couldn't find any good resources explaining how should you treat or pass the user input so the end process gets to interpret special codes appropriately, thus achieving a truly interactive session.
The base code: http://dl.dropbox.com/u/15117414/pty.c