[Twisted-Python] understanding IConsumer
Glyph
glyph at twistedmatrix.com
Tue Sep 8 00:37:07 MDT 2015
> On Sep 2, 2015, at 6:08 PM, Roshan Cherian <cherian.rosh at gmail.com> wrote:
>
> Hi Team,
Hi Roshan!
Sorry it took a while to get back to you. Busy week.
> I am sorry if this is coming off as a newbie question. Its probably because I don't understand it enough.
Newbie questions are fine, no need to apologize :).
> I would like to:
>
> 1. connectTCP to a host, port
You should not use connectTCP directly. Use Endpoints: <https://twistedmatrix.com/documents/15.4.0/core/howto/endpoints.html <https://twistedmatrix.com/documents/15.4.0/core/howto/endpoints.html>>. (But this doesn't affect the rest of your question.)
> 2. use the transport to write
Should be easy enough; `self.transport.write´.
> 3. Use consumer to read from the transport what the tcp server has written to
You don't need to use the producer / consumer API just to read from the transport. The transport does this automatically, and calls your protocol's dataReceived method every time data is received from the transport.
> I wasn't able to find information on consumer and how it gets triggered when data is available especially in the case I have
I'm not sure what you mean about "how it gets triggered"; the producer and consumer APIs are documented here: <https://twistedmatrix.com/documents/15.4.0/core/howto/producers.html <https://twistedmatrix.com/documents/15.4.0/core/howto/producers.html>> but it would help if you could explain what exactly you're trying to achieve with them.
-glyph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20150907/c02d7b00/attachment-0002.html>
More information about the Twisted-Python
mailing list