anyio的websocket协议实现

anysocks的Python项目详细描述


任何袜子

这个库基于Sans-IO library wsproto实现the WebSocket protocol。 i/o由anyio project处理,这使得这个库与asyncio、trio和curio兼容。

Build StatusMaintainabilityCodeFactorDocumentation StatusPyPI version

安装

这个库需要Python3.5+。您可以直接从pypi安装它:

python3 -m pip install -U anysocks

如果您希望使用尖端的开发版本,请直接从github安装:

python3 -m pip install -U git+https://github.com/clamor-py/anysocks@master#egg=anysocks

文档

本自述文件仅提供一个简短的概述,请参阅完整的文档here

示例

importanyiofromanysocksimportopen_connectionasyncdefmain():asyncwithopen_connection('wss://echo.websocket.org')ascon:print('Connection established!')# First, let's send some text to the server.text=input('What to send? ')awaitcon.send(text)# Now, we receive and verify the server's response.message=awaitcon.get_message()assertmessage==text,"Received {}, expected {}".format(message,text)print('Connection closed with code {}',con.close_code.value)anyio.run(main)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
构造函数的java条件调用   类Dog中的java构造函数Dog不能应用于给定类型   java jsch和运行“sudo su”   java将队列和堆栈相互复制   java如何在netbeans项目的文件夹中添加库   java While循环在我的代码中不存在   如何在XML中使用java方法的返回值   java是否可以在不写入文件的情况下将字符串/字节数组作为文件发布?   java为什么这些字符串不相等?   sockets客户机-服务器java编程,用户可选择   java如何在SpringMVC和hibernate中保存模型返回视图的列表   java如何修复组织。openqa。硒。WebDriverException:未知错误   Java,Ant错误:编码Cp1252的不可映射字符   JAVAlang.ClassCastException:[Ljava.lang.String;与java.lang.String不兼容   java如何使用JDK8(可选)为空字段创建自定义IntelliJ getter模板   java Tomcat6响应。sendRedirect()404错误