[Twisted-Python] servers that are also clients? (newbie question)
Eugene Coetzee
projects at reedflute.com
Wed Mar 16 12:01:12 EST 2005
mikah at ceruleansoftware.com wrote:
> My app is both a server and client at the same time. It takes
>requests from some clients, and also relays these requests
>(suitably reformatted) to a pair of third-party servers. In
>this sense, it is acting as a client (I intend to use
>ReconnectingClient for this).
>
>
>
I'm busy doing the same kind of thing.
I use a separate server/client factory which I connect with some
abstraction layer I choose to call a conductor. The conductor also
manages a buffer and uses callbacks into the server/client protocol
instances.
I'm sure there must be a more clever Twisted way of doing this but I
couldn't find any docs.
here is how the contraption starts up.
*************************************
from eva_config import EvaConfig
from eva_conductor import Conductor
from controller import ControllerFactory
from courier import CourierClientFactory
from twisted.application import service,internet
resourcemap=EvaConfig().getResourceMap()
conductor=Conductor(resourcemap).configure()
application=service.Application('eva',uid=1000,gid=100)
controllerfactory = ControllerFactory(conductor)
internet.TCPServer(8831,controllerfactory).setServiceParent(
service.IServiceCollection(application))
courierclientfactory = CourierClientFactory(conductor)
internet.TCPClient("server1","ftp",courierclientfactory).setServiceParent(
service.IServiceCollection(application))
****************************************
Works for me.
Eugene Coetzee
Web -> www.reedflute.com
===============================================
More information about the Twisted-Python
mailing list