[Twisted-Python] Returning a response for an HTTP query that requires upstream IO.

2020-04-22 Thread Go Luhng
I'd like to develop a server that maintains a TCP connection to an upstream server, and listens for HTTP requests. Upon receiving an HTTP request, the server will send a message upstream, wait for a response, and return an HTTP response to the client which made the request. My background is in wri

Re: [Twisted-Python] Inheriting DatagramProtocol, which is an old-style class

2020-02-09 Thread Go Luhng
rten ter Huurne wrote: > > On Saturday, 8 February 2020 01:50:04 CET Go Luhng wrote: > > > I am creating a child class > > > `Child(twisted.internet.protocol.DatagramProtocol)` to implement a > > > custom UDP multicast protocol. > > > > > > I nee

[Twisted-Python] Inheriting DatagramProtocol, which is an old-style class

2020-02-07 Thread Go Luhng
I am creating a child class `Child(twisted.internet.protocol.DatagramProtocol)` to implement a custom UDP multicast protocol. I need to add an `__init__()` to `Child`, but as part of that I need to call `super()` which is impossible because `DatagramProtocol` is old-style. How should I proceed?

Re: [Twisted-Python] Supporting a two-part client protocol.

2020-02-06 Thread Go Luhng
Thanks for the detailed responses, Colin and Barry. I have a followup question about sans-io. From the document: > For input (that is, receiving data from the network), the calling code is responsible for delivering code to the implementation via a single input (often via a method called receive_b

Re: [Twisted-Python] Supporting a two-part client protocol.

2020-02-04 Thread Go Luhng
Thanks Colin and Barry for the reply. I read the sans-io docs and it is an attractive approach. I believe I have a plan going forward, but I'm not sure what you mean by explicit vs implicit state machine, if you care to elaborate. ___ Twisted-Python mai

Re: [Twisted-Python] Supporting a two-part client protocol.

2020-02-03 Thread Go Luhng
> Colin Dunklau wrote: > > Assuming the header has a fixed length, It does. The header is just a serialized C struct, so it's fully-specified for length and offset of each field. > OTOH, that's for stream protocols, so if you want to eventually handle > UDP, it's probably nicer to do the full san

[Twisted-Python] Supporting a two-part client protocol.

2020-02-03 Thread Go Luhng
Hi there, I'm planning to use Twisted to write a client for the following protocol: Each messages is composed of two separate messages: 1. A header, which is a serialized C struct, containing multiple fields, among them a `length` field. 2. A Protocol Buffer payload, which length is specified by