[Twisted-Python] using ClientFactory from within a server

Greg greg at digitalinfo.net
Mon Sep 29 06:07:57 MDT 2003


>>		reactor.connectTCP(host, port, factory2)
>>		reactor.run()
>>    
>>
>
>  Remove the above call to "reactor.run() and see what happens.
>
>  
>
>>		print "Returned from sending email"
>>		# ^ Never gets to this point
>>    
>>
Thanks. Now I am getting closer. But a strange (to me) thing happens. 
When I connect to the Echo server and send it a string, it does 
correctly run the MySMTP code. But it does not return and execute the 
'print "Returned from sending email"' statement until I connect to the 
Echo server again and send another string. Any idea why this is 
happening? Is there a way to disconnect factory2 from the reactor after 
I have sent the "QUIT" string (or when 
MySMTPClientFactory.clientConnectionLost() gets called)?

>>		
>>class MySMTP(Protocol):
>>[snip]
>>				
>>    
>>
>
>  I don't understand why you aren't using twisted.protocols.smtp.
>  
>
The use of SMTP is just an example. In reality I'm talking a different 
protocol, but I wanted to use a common protocol like SMTP in my example 
so that someone on the list could easily test my code.





More information about the Twisted-Python mailing list