如何在ironpython中实现websockets?
Ironpython似乎只支持带有INET头的套接字(IPv4)。
我需要通过主机url wss:// host .websocket.org进行连接。
#socket
import socket
host = "wss://echo.websocket.org"
port = 8000
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((host,port))
s.send("Hello World")
finally:
s.close()
print s当我尝试连接时,它会给出一个:
[Errno 11001] no addresses of the specified family associated with host有没有更好的方法来解决这个问题?例如,导入一个专门处理websockets的外部库?
发布于 2018-12-17 05:39:26
我有一个类似的问题(我正在使用ObsWebsocket在python中控制obs ),我试图使用websocket,但我得到了一个类似的错误: Errno 10044在这个地址系列中不存在对指定套接字类型的支持最后,我找到了一个解决方法。我使用子进程处理所有IronPython内容,并使用Python3脚本通过套接字执行通信
我给你发一段我的代码。我希望它能有所帮助:
from subprocess import Popen, PIPE
creturn_code = Popen("ipy IronPythonScript.py", shell=True, stdout = PIPE) #You can change the ipy for py and use an similar code in IronPython
rrline = creturn_code.stdout.readline() #This read the stdout of the script
rline = str(rrline)[2: (len(rrline))] #This remove the fking b'' that is always (i dont know why)
if(rline != ""): #Check that the output of the another process realy contains something在这里,您可以实现所需的所有功能
我在Python3上使用了它,并且它工作了。IronPython处理所有的dlls事务,而python3处理所有的通信
如果我的英语不是很好,对不起,我是阿根廷人
https://stackoverflow.com/questions/51168508
复制相似问题