Debian Codegraph @

testing/web-platform/tests/tools/third_party/websockets/example/legacy/unix_client.py

raw
1 #!/usr/bin/env python
2
3 # WS client example connecting to a Unix socket
4
5 import asyncio
6 import os.path
7 import websockets
8
9 async def hello():
10 socket_path = os.path.join(os.path.dirname(__file__), "socket")
11 async with websockets.unix_connect(socket_path) as websocket:
12 name = input("What's your name? ")
13 await websocket.send(name)
14 print(f">>> {name}")
15
16 greeting = await websocket.recv()
17 print(f"<<< {greeting}")
18
19 asyncio.run(hello())