简体   繁体   中英

Twisted suggestion for TCP client spawn processes

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM