def createConnection(self, addr): """Creates a virtual connection over UDP""" protocol = self.factory.buildProtocol(addr) s = self.sessionno self.sessionno = s + 1 transport = Connection(self.socket.dup(), protocol, addr, self, s) protocol.makeConnection(transport, self) return transport
def createConnection(self, addr): """Creates a virtual connection over UDP""" protocol = self.factory.buildProtocol(addr) s = self.sessionno self.sessionno = s+1 transport = Connection(self.socket.dup(), protocol, addr, self, s) protocol.makeConnection(transport, self) return transport
def portGotSocket(tcpPort, skt): # make this into an address... protocol = tcpPort.factory.buildProtocol(None) transport = JConnection(skt, protocol) # make read and write blockers protocol.makeConnection(transport, tcpPort) wb = WriteBlocker(transport, theMultiplexor.q) wb.start() transport.writeBlocker = wb ReadBlocker(transport, theMultiplexor.q).start()
def testMessages(self): protocol = MySMTPClient() protocol.makeConnection(self.transport) protocol.lineReceived('220 hello') protocol.lineReceived('250 nice to meet you') protocol.lineReceived('250 great') protocol.lineReceived('250 great') protocol.lineReceived('354 go on, lad') protocol.lineReceived('250 gotcha') protocol.lineReceived('221 see ya around') if self.output.getvalue() != self.expected_output: raise AssertionError(`self.output.getvalue()`)
def testMessages(self): self.output = StringIOWithoutClosing() self.transport = protocols.protocol.FileWrapper(self.output) protocol = MyVirtualPOP3() protocol.makeConnection(self.transport) protocol.factory = self.factory protocol.lineReceived('APOP [email protected] world') protocol.lineReceived('UIDL') protocol.lineReceived('RETR 1') protocol.lineReceived('QUIT') if self.output.getvalue() != self.expectedOutput: print `self.output.getvalue()` print `self.expectedOutput` raise AssertionError(self.output.getvalue(), self.expectedOutput)
def testMessages(self): protocol = protocols.smtp.DomainSMTP() protocol.factory = self.factory protocol.makeConnection(self.transport) protocol.lineReceived('HELO yyy.com') for message in self.messages: protocol.lineReceived('MAIL FROM:<%s>' % message[0]) for target in message[1]: protocol.lineReceived('RCPT TO:<%s>' % target) protocol.lineReceived('DATA') protocol.dataReceived(message[2]) protocol.lineReceived('.') protocol.lineReceived('QUIT') if self.mbox != self.factory.domains['baz.com'].messages: raise AssertionError(self.server.domains['baz.com'].messages)
def doRead(self): """Called when my socket is ready for reading. This accepts a connection and callse self.protocol() to handle the wire-level protocol. """ try: for i in range(self.numberAccepts): try: skt,addr = self.socket.accept() except socket.error, e: if e.args[0] == EWOULDBLOCK: self.numberAccepts = i break raise protocol = self.factory.buildProtocol(addr) s = self.sessionno self.sessionno = s+1 transport = self.transport(skt, protocol, addr, self, s) protocol.makeConnection(transport, self) else: