[Twisted-Python] Create client in Server factory

Grégoire Leroy gregoire.leroy at retenodus.net
Wed Oct 31 01:14:34 MDT 2012


Hi,

I have a server who receive data from clients A/B/C (remote machines). I want 
to use a client D (on the same machine than the server) to send this data to 
another server (remote).

The difficulty is, I want to use the same client D connection for any client. I 
don't want open an new connection each time.

First thing I would think is to create the connection in my server factory, 
and use client's methods in my server protocol, for example with
[...]
class LocalProxyFactory(Factory):
        def __init__(self):
                f = LocalProxyClientFactory()
                reactor.connectTCP("retenodus.net", 4242, f)
                reactor.run()
[...]
But in this case, code execution will stay in the reactor, right ?

I have read that :
http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#HowdoImakeinputononeconnectionresultinoutputonanother
But I don't know how it can be applied to my situation.

Thanks,
Grégoire Leroy




More information about the Twisted-Python mailing list