Python Forum
Multiple connect statements
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple connect statements
#1
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()
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020