Example #1
0
def run_client(instance):
    global c, client_thread
    main_app.switch_UI()
    print "Connecting to a server..."
    sys.stdout.write("Server?: ")
    host = stdin.readline().rstrip("\n")
    sys.stdout.write("Port?: ")
    port = stdin.readline().rstrip("\n")
    #spawn client thread
    c = Client(host, int(port))

    
    client_thread = NetworkThread("client", c)
    client_thread.start()
Example #2
0
def run_server(instance):
    global s, server_thread
    global c, client_thread
    main_app.switch_UI()
    print "Starting a server..."
    sys.stdout.write("Server?: ")
    host = stdin.readline().rstrip("\n")
    sys.stdout.write("Port?: ")
    port = stdin.readline().rstrip("\n")
    #spawn server thread
    s = ServerObj(localaddr=(host, int(port)))
    #spawn client thread
    c = Client(host, int(port))

    server_thread = NetworkThread("server", s)
    server_thread.start()
    client_thread = NetworkThread("client", c)
    client_thread.start()