首页 > 解决方案 > 多服务器套接字条件

问题描述

我一直在尝试在下面执行此操作,但没有成功。我需要为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()

标签: pythonpython-3.xmultithreadingsocketsclient-server

解决方案


推荐阅读