1
여기 sendQuote 메서드에서 바이트 배열을 보내고 싶지만 twisted는 문자열을 취하는 전송 쓰기 메서드를 제공합니다. 어떻게하면 Twisted를 사용하여 응답으로 바이트 배열을 보낼 수 있습니다. 감사.twisted python을 사용하여 바이트 배열을 보내는 방법
class QuoteProtocol(protocol.Protocol):
def __init__(self, factory):
self.factory = factory
def connectionMade(self):
self.sendQuote()
def sendQuote(self):
#self.file.write(bytearray([0x00, 0x31, 0x34, 0x32, 0x30, 0x30, 0x30, 0x30, 0x31, 0x11, 0x0c, 0x00, 0xfd, 0x09, 0x00, 0x2f, 0xe7, 0x5e, 0x3a, 0x08, 0x3c, 0x00, 0x00, 0x00, 0x49, 0x95]))
self.transport.write("Quote reecevied")
def dataReceived(self, data):
print "Received quote:", data
self.transport.loseConnection()