Apr-20-2021, 06:18 PM
Hello,
does anyone know as to how I can create 2 connect statements inside a client?
Client should connect to 1 server in a particular scenario. And if the scenario changes it should connect with another one.
What condition do I need to state for stillConnected() that the existing connection creates a new socket.
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()
does anyone know as to how I can create 2 connect statements inside a client?
Client should connect to 1 server in a particular scenario. And if the scenario changes it should connect with another one.
What condition do I need to state for stillConnected() that the existing connection creates a new socket.
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()