Twisted - listenTCP and connectTCP on the same reactor?
Ed Young
ejy712 at comcast.net
Sat Jun 14 20:01:19 EDT 2003
I must say, Twisted really is worth a look if you are doing
network programming. I just started using it a week or so
ago, it really is amazing.
The question: I am working on an application to application
data transporter. It has to listen as well as connect.
I've got the listenTCP working well. I am having trouble
getting the connectTCP to work. I have a running reactor
and I want to 'attach' a connectTCP to it. How do I do
this?
The reactor is started at the beginning of the program,
in a completely different file than the one depicted
below. The following connection needs to be made when
messages want to be transported to another queue manager.
I made the following attempt (lots of details omitted):
class XmitProtocol(Protocol):
def connectionMade(self):
self.xmitq = self.factory.xmitq
class TransporterFactory(ClientFactory):
def buildProtocol(self, addr):
return XmitProtocol()
def startTransporter(qmgr, xmitq):
f = TransporterFactory()
f.qmgr = qmgr
f.xmitq = xmitq
reactor.connectTCP(xmitq.host, xmitq.port, f)
I am getting the error:
File "/home/ejy/src/py/aadm-twisted/aadm/aadmd/
XmitProtocol.py", line 33, in connectionMade
self.xmitq = self.factory.xmitq
exceptions.AttributeError: XmitProtocol instance has
no attribute 'factory'
This seems to be contradictory to what the docs say.
Any guidance in this would be greatly appreciated...
More information about the Python-list
mailing list