Twisted suggestion for TCP client spawn processes

216 Views Asked by At

With a script that should start 3 different connection as client to 3 different servers, is it advisable to spawn the 3 clients? or it is unnecessary?

        p1 = protocol.ClientCreator(reactor, test1
            ).connectTCP(Host, Port)
        p2 = protocol.ClientCreator(reactor, test2
            ).connectTCP(Host2, Port)
        p3 = protocol.ClientCreator(reactor, test3
            ).connectTCP(Host2, Port)
1

There are 1 best solutions below

2
On

It's not really clear what you're asking here. However, one thing I can confirm is that a TCP connection is between exactly two hosts: one client (responsible for "connecting") and one server (responsible for "accepting") (or sometimes simultaneous open where there are two clients and zero servers, but no one actually does that).

If you want to connect to three servers, you must create at least three connections.