我尝试用twisted实现一个简单的客户端,使用数据报和命名管道。在
我将协议定义如下:
class ConsoleProtocol(protocol.DatagramProtocol):
def __init__(self, machine, console_path):
self.console_path = console_path
self.transport = None
def datagramReceived(self, datagram, addr):
self.logger.debug("datagramReceived()")
# blah, doing stuff !
def sendHalt(self):
self.logger.debug("sending message to fifo %s", self.console_path)
self.transport.write("ahaha", self.console_path)
并将其连接到UNIX客户端端点:
^{pr2}$但是在执行sendHalt()
方法时,传输参数是NoneType
。在Twisted中使用UNIX客户端的正确方法是什么?在
端点不适用于数据报协议。您需要使用
reactor.listenUNIXDatagram(console_path, console_protocol)
。一定不要混淆UNIX套接字和命名管道:它们是不同的,不兼容的东西。Twisted不支持通过命名管道进行通信。在相关问题 更多 >
编程相关推荐