What do you mean when you say "connect through telnet"? Telnet is an application layer protocol, it specifies the syntax and semantics of telnet communication. There is really no such thing as connecting through telnet in this context.
I'll throw together the example you are asking for, hold on.