<s> from gevent import monkey ; monkey . patch_all ( ) <EOL> import gevent <EOL> from ws4py . client . geventclient import WebSocketClient <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> ws = WebSocketClient ( '<STR_LIT>' , protocols = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> ws . connect ( ) <EOL> ws . send ( "<STR_LIT>" ) <EOL> print ( ( ws . receive ( ) , ) ) <EOL> ws . send ( "<STR_LIT>" ) <EOL> print ( ( ws . receive ( ) , ) ) <EOL> def incoming ( ) : <EOL> while True : <EOL> m = ws . receive ( ) <EOL> if m is not None : <EOL> m = str ( m ) <EOL> print ( ( m , len ( m ) ) ) <EOL> if len ( m ) == <NUM_LIT> : <EOL> ws . close ( ) <EOL> break <EOL> else : <EOL> break <EOL> print ( ( "<STR_LIT>" , ) ) <EOL> def outgoing ( ) : <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT:5> ) : <EOL> ws . send ( "<STR_LIT:*>" * i ) <EOL> ws . send ( "<STR_LIT>" ) <EOL> greenlets = [ <EOL> gevent . spawn ( incoming ) , <EOL> gevent . spawn ( outgoing ) , <EOL> ] <EOL> gevent . joinall ( greenlets ) </s>
