最終更新:2021-08-13 (金) 11:52:37 (977d)  

Python/websockets
Top / Python / websockets

https://github.com/aaugustin/websockets

https://websockets.readthedocs.io/en/stable/index.html

Requirements

  • websockets requires Python 3.6.1?

ベース

サーバ

websockets.serve

websocket

  • websocket.recv?
  • websocket.send?

クライアント

  • import asyncio
    import websockets
    
    async def hello():
        uri = "ws://localhost:8765"
        async with websockets.connect(uri) as websocket:
            await websocket.send("Hello world!")
            await websocket.recv()
    
    asyncio.get_event_loop().run_until_complete(hello())

websockets.connect

websocket

  • websocket.recv?
  • websocket.send?

参考