Path: blob/main/python/python-wasm/data/socket/client.py
1067 views
"""12Run the server first, then run this via34python-wasm client.py56You can also run either the client or server with python-native7to narrow down problems.89"""1011import socket, time121314def f():15# TODO: This currently "hangs for 5 seconds" even16# though the other side is ready. The problem17# is that poll_oneoff or pollSocket (in posix-node)18# need to be improved.19conn = socket.create_connection(("localhost", 2000), timeout=5)20print("connected to port 2000")21#conn.settimeout(1)2223print("*" * 80)24print("conn =", conn)25print("*" * 80)2627t = time.time()28print(conn.recv(6))29print("time = ", time.time() - t)3031t = time.time()32print(conn.send(b"CoWasm"))33print("time = ", time.time() - t)3435#conn.shutdown(socket.SHUT_RD)363738f()394041