<s> import select <EOL> import socket <EOL> from Rpyc . Utils . Serving import ( <EOL> log , <EOL> create_listener_socket , <EOL> DEFAULT_PORT , <EOL> SocketStream , <EOL> Channel , <EOL> Connection ) <EOL> def main ( port = DEFAULT_PORT ) : <EOL> sock = create_listener_socket ( port ) <EOL> connections = [ ] <EOL> while True : <EOL> rlist , wlist , xlist = select . select ( [ sock ] + connections , [ ] , [ ] ) <EOL> if sock in rlist : <EOL> rlist . remove ( sock ) <EOL> newsock , name = sock . accept ( ) <EOL> conn = Connection ( Channel ( SocketStream ( newsock ) ) ) <EOL> conn . sockname = name <EOL> connections . append ( conn ) <EOL> log ( "<STR_LIT>" , conn . sockname ) <EOL> for conn in rlist : <EOL> try : <EOL> conn . serve ( ) <EOL> except ( EOFError , socket . error ) : <EOL> connections . remove ( conn ) <EOL> log ( "<STR_LIT>" , conn . sockname ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
