<s> import sys <EOL> from circuits . io import File <EOL> from circuits import handler , Component <EOL> from circuits . net . sockets import TCPClient <EOL> from circuits . net . events import connect , write <EOL> class Telnet ( Component ) : <EOL> channel = "<STR_LIT>" <EOL> def init ( self , host , port ) : <EOL> self . host = host <EOL> self . port = port <EOL> TCPClient ( channel = self . channel ) . register ( self ) <EOL> File ( sys . stdin , channel = "<STR_LIT>" ) . register ( self ) <EOL> def ready ( self , socket ) : <EOL> self . fire ( connect ( self . host , self . port ) ) <EOL> def read ( self , data ) : <EOL> print ( data . strip ( ) ) <EOL> @ handler ( "<STR_LIT>" , channel = "<STR_LIT>" ) <EOL> def read_user_input ( self , data ) : <EOL> self . fire ( write ( data ) ) <EOL> host = sys . argv [ <NUM_LIT:1> ] <EOL> port = int ( sys . argv [ <NUM_LIT:2> ] ) <EOL> Telnet ( host , port ) . run ( ) </s>
