views:

70

answers:

1

I am running an HTTP server using the twisted framework. Is there any way I can "manually" ask it to process some payload? For example, if I've constructed some Ethernet frame can I ask twisted's reactor to handle it just as if it had just arrived on my network card?

A: 

What is the use-case?

Perhaps you want to create your own Datagram Protocol

At the base, the place where you actually implement the protocol parsing and handling, is the DatagramProtocol class. This class will usually be decended from twisted.internet.protocol.DatagramProtocol. Most protocol handlers inherit either from this class or from one of its convenience children. The DatagramProtocol class receives datagrams, and can send them out over the network. Received datagrams include the address they were sent from, and when sending datagrams the address to send to must be specified.

If you want to see wire-level transmissions rather than inject them, install and run WireShark, the fantastic, free packet sniffer.

Tom Leys
The use-case: I have a tunnel setup between two computers. One machine is running a (twisted) web server. When that machine receives a packet to TCP port 80 over the tunnel, I'd like to have twisted process that packet (as if it had arrived "normally" via the machine's NIC). When the server generates TCP/IP replies, I'd like to send them back via the tunnel.
David Underhill
It is possible to set up port forwarding through a SSH tunnel. Instead of a custom solution, you could run HAProxy or similar and have it forward the connections to twisted on the other computer via the tunnel.
Tom Leys