'Create a new L{IListeningPort} from an already-initialized socket.
This just dispatches to a suitable port implementation (eg from
L{IReactorTCP}, etc) based on the specified C{addressFamily}.
@see: L{twisted.internet.interfaces.IReactorSocket.adoptStreamPort}'

def adoptStreamPort(self, fileDescriptor, addressFamily, factory):

    if (addressFamily not in self._supportedAddressFamilies):
        raise error.UnsupportedAddressFamily(addressFamily)
    if (unixEnabled and (addressFamily == socket.AF_UNIX)):
        p = unix.Port._fromListeningDescriptor(self, fileDescriptor, factory)
    else:
        p = tcp.Port._fromListeningDescriptor(self, fileDescriptor, addressFamily, factory)
    p.startListening()
    return p
