python - 多服务器套接字条件
问题描述
我一直在尝试在下面执行此操作,但没有成功。我需要为stillConnected()声明现有连接创建新套接字的条件是什么。
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(host, port)
s.send("some data")
# don't close socket just yet...
# do some other stuff with the data (normal string operations)
if s.**stillconnected()** is true:
s.send("some more data")
if s.**stillconnected()** is false:
# create another socket with another client/server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(host11, port11)
s.send("some data")
s.close()
解决方案
推荐阅读
- python - 从 tkinter 窗口中提取数据。获取类似于Matlab的inputdlg的函数
- c++ - 将大文件读入char数组的正确方法
- python - 输入函数名称错误
- android - 在...行找不到可执行代码。安卓
- c# - 如何删除 Windows 凭据
- javascript - ElementHandle 与 DOM 元素有何不同?
- arrays - 根据名称返回单元格的最后两个值
- groovy - 将 RapidMiner ExampleSet 属性转换为 FileObject
- html-table - HTML - 如何避免单元格表中的文本在单元格很短时溢出?
- javascript - REACT 渲染为空