Ejemplo n.º 1
0
def main():
    for i in range(1):
        client_socket = socket.socket()
        client_socket.connect(('localhost', env.get_server_port()))
        # client_socket.connect(('52.74.148.102', env.get_server_port()))
        ct = ClientThread(client_socket)
        print('[Main] Starting ClientThread {}'.format(ct.getName()))
        ct.start()
Ejemplo n.º 2
0
def main():
    server_socket = socket.socket()
    server_socket.bind(('', env.get_server_port()))
    server_socket.listen(env.get_tcp_listen_backlog())
    while True:
        print('[Main] Waiting for a new connection request...')
        client_socket, address = server_socket.accept()
        print('[Main] Connection established with {}'.format(address))
        cht = ClientHandlerThread(client_socket)
        print('[Main] Starting ClientHandlerThread {}'
              .format(cht.name))
        cht.start()
Ejemplo n.º 3
0
 def run(self):
     logger.i('I started')
     # Start the control thread
     self.__ct.start()
     # Start listening
     server_sock = socket.socket()
     server_port = env.get_server_port()
     server_sock.bind(('', server_port))
     server_sock.listen(env.get_tcp_listen_backlog())
     logger.i('Listening on server port {}'.format(server_port))
     while True:
         # Main loop
         logger.i('Waiting for a new client connection')
         client_sock, address = server_sock.accept()
         logger.i('Connection established with {}'.format(address))
         # Dispatch
         cht = ClientHandlerThread(self, client_sock)
         logger.i('Starting ClientHandlerThread {}'.format(cht.name))
         cht.start()