diff options
Diffstat (limited to 'testing/web-platform/tests/tools/third_party/websockets/example/legacy/unix_client.py')
-rw-r--r-- | testing/web-platform/tests/tools/third_party/websockets/example/legacy/unix_client.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/third_party/websockets/example/legacy/unix_client.py b/testing/web-platform/tests/tools/third_party/websockets/example/legacy/unix_client.py new file mode 100644 index 0000000000..9261567303 --- /dev/null +++ b/testing/web-platform/tests/tools/third_party/websockets/example/legacy/unix_client.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +# WS client example connecting to a Unix socket + +import asyncio +import os.path +import websockets + +async def hello(): + socket_path = os.path.join(os.path.dirname(__file__), "socket") + async with websockets.unix_connect(socket_path) as websocket: + name = input("What's your name? ") + await websocket.send(name) + print(f">>> {name}") + + greeting = await websocket.recv() + print(f"<<< {greeting}") + +asyncio.run(hello()) |