def adoptStreamPort(self, fileno, addressFamily, factory): """ Fake L{IReactorSocket.adoptStreamPort}, that logs the call and returns an L{IListeningPort}. """ if addressFamily == AF_INET: addr = IPv4Address('TCP', '0.0.0.0', 1234) elif addressFamily == AF_INET6: addr = IPv6Address('TCP', '::', 1234) else: raise UnsupportedAddressFamily() self.adoptedPorts.append((fileno, addressFamily, factory)) return _FakePort(addr)
def adoptDatagramPort(self, fileno, addressFamily, protocol, maxPacketSize=8192): """ Fake L{IReactorSocket.adoptDatagramPort}, that logs the call and returns a fake L{IListeningPort}. @see: L{twisted.internet.interfaces.IReactorSocket.adoptDatagramPort} """ if addressFamily == AF_INET: addr = IPv4Address('UDP', '0.0.0.0', 1234) elif addressFamily == AF_INET6: addr = IPv6Address('UDP', '::', 1234) else: raise UnsupportedAddressFamily() self.adoptedPorts.append( (fileno, addressFamily, protocol, maxPacketSize)) return _FakePort(addr)