コード例 #1
0
 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
コード例 #2
0
ファイル: udp.py プロジェクト: lhl/songclub
 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
コード例 #3
0
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()
コード例 #4
0
ファイル: jnternet.py プロジェクト: lhl/songclub
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()
コード例 #5
0
 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()`)
コード例 #6
0
 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)
コード例 #7
0
 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)
コード例 #8
0
ファイル: tcp.py プロジェクト: katrinleinweber/songclub
    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: