【问题标题】:Is there a way to resend UDP packets using Twisted?有没有办法使用 Twisted 重新发送 UDP 数据包?
【发布时间】:2011-05-04 16:25:25
【问题描述】:

问题:简单的 UDP 代理 - 在端口 X 上接收来自多个源的 UDP 数据包并将它们转发(重新发送)到端口 Z 上的 IP Y。

描述:我能够使用twisted创建一个简单的UDP服务器,并轻松接收传入的数据包。但是,我找不到使用 Twisted 进一步重新发送这些数据包(它们的数据)的方法。是否有一种特定的、犹太洁食和类似 Twisted 的方式来处理 Twisted 中的接收数据,或者我应该在 Twisted 中处理接收到的数据的方法中使用简单的 python sock.sendto 方式?

【问题讨论】:

    标签: python proxy udp twisted forwarding


    【解决方案1】:

    你做这样的事情:

    class MyProtocol(DatagramProtocol):
        def datagramReceived(self, datagram, addr):
            # use self.transport.write to send stuff
            some_where = ('192.168.0.1',5001)
            self.transport.write( datagram, some_where )
    

    【讨论】:

      猜你喜欢
      • 2022-01-17
      • 1970-01-01
      • 2016-10-26
      • 1970-01-01
      • 1970-01-01
      • 2013-02-09
      • 1970-01-01
      • 1970-01-01
      • 2018-01-20
      相关资源
      最近更新 更多