def _loopbackTLSConnection(serverOpts, clientOpts):
 class GreetingServer(protocol.Protocol, ):
  greeting = 'greetings!'
  def connectionMade(self):
   self.transport.write(self.greeting)
 class ListeningClient(protocol.Protocol, ):
  data = ''
  lostReason = None
  def dataReceived(self, data):
   self.data += data
  def connectionLost(self, reason):
   self.lostReason = reason
 clientFactory = TLSMemoryBIOFactory(clientOpts, isClient=True, wrappedFactory=protocol.Factory.forProtocol(GreetingServer))
 serverFactory = TLSMemoryBIOFactory(serverOpts, isClient=False, wrappedFactory=protocol.Factory.forProtocol(ListeningClient))
 (sProto, cProto, pump) = connectedServerAndClient((lambda : serverFactory.buildProtocol(None)), (lambda : clientFactory.buildProtocol(None)))
 return (sProto, cProto, pump)

def _loopbackTLSConnection ( serverOpts , clientOpts ) : class GreetingServer ( protocol . Protocol , ) : greeting = 'greetings!' def connectionMade ( self ) : self . transport . write ( self . greeting ) class ListeningClient ( protocol . Protocol , ) : data = '' lostReason = None def dataReceived ( self , data ) : self . data += data def connectionLost ( self , reason ) : self . lostReason = reason clientFactory = TLSMemoryBIOFactory ( clientOpts , isClient = True , wrappedFactory = protocol . Factory . forProtocol ( GreetingServer ) ) serverFactory = TLSMemoryBIOFactory ( serverOpts , isClient = False , wrappedFactory = protocol . Factory . forProtocol ( ListeningClient ) ) ( sProto , cProto , pump ) = connectedServerAndClient ( ( lambda : serverFactory . buildProtocol ( None ) ) , ( lambda : clientFactory . buildProtocol ( None ) ) ) return ( sProto , cProto , pump )
common implementation code for both l{loopbacktlsconnection} and l{loopbacktlsconnectioninmemory} .