def __init__(self, initType, *args):
        super(TCPTransport, self).__init__()

        if isinstance(initType, ExternalInterfaceTransportInit):
            # External process that is going to talk "in".  There is
            # no parent, and the child is the systemAdmin.
            capabilities, logDefs = args
            adminRouting     = False
            self.txOnly      = False  # communications from outside-in are always local and therefore not restricted.
            convAddr = capabilities.get('Convention Address.IPv4', '')
            if convAddr and type(convAddr) == type( (1,2) ):
                externalAddr = convAddr
            elif type(convAddr) == type("") and ':' in convAddr:
                externalAddr = convAddr.split(':')
                externalAddr      = externalAddr[0], int(externalAddr[1])
            else:
                externalAddr = (convAddr, capabilities.get('Admin Port', DEFAULT_ADMIN_PORT))
            templateAddr     = ActorAddress(TCPv4ActorAddress(None, 0, external = externalAddr))
            self._adminAddr  = self.getAdminAddr(capabilities)
            self._parentAddr = None
            isAdmin = False
        elif isinstance(initType, TCPEndpoint):
            instanceNum, assignedAddr, self._parentAddr, self._adminAddr, adminRouting, self.txOnly = initType.args
            isAdmin = assignedAddr == self._adminAddr
            templateAddr = assignedAddr or ActorAddress(TCPv4ActorAddress(None, 0,
                                                                          external = (self._parentAddr or
                                                                                      self._adminAddr or
                                                                                      True)))

        else:
            thesplog('TCPTransport init of type %s unsupported', type(initType), level=logging.ERROR)
            raise ActorSystemStartupFailure('Invalid TCPTransport init type (%s)'%type(initType))

        self.socket = socket.socket(*templateAddr.addressDetails.socketArgs)
        self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.socket.bind(*templateAddr.addressDetails.bindArgs)
        self.socket.listen(LISTEN_DEPTH)
        # N.B.  myAddress is actually the address we will export for
        # others to talk to us, not the bind address.  The difference
        # is that we bind to '0.0.0.0' (inaddr_any), but that's not a
        # valid address for people to send stuff to us.  The
        # self.socket socket name is likely inaddr_any but has the
        # valid port, whereas the templateAddr has our actual public
        # address.
        if isAdmin and self.txOnly:
            # Must be the admin, and in txOnly mode
            self.myAddress = ActorAddress(TXOnlyAdminTCPv4ActorAddress(
                templateAddr.addressDetails.connectArgs[0][0],
                self.socket.getsockname()[1],
                external = True))
        elif adminRouting:
            self.myAddress = ActorAddress(RoutedTCPv4ActorAddress(
                templateAddr.addressDetails.connectArgs[0][0],
                self.socket.getsockname()[1],
                self._adminAddr,
                txOnly = self.txOnly,
                external = True))
        else:
            self.myAddress = ActorAddress(TCPv4ActorAddress(
                templateAddr.addressDetails.connectArgs[0][0],
                self.socket.getsockname()[1],
                external = True))
        self._transmitIntents = {}  # key = fd, value = tx intent
        self._waitingTransmits = []  # list of intents without sockets
        self._incomingSockets = {}  # key = fd, value = TCP Incoming
        self._incomingEnvelopes = []
        self._watches = []
        if REUSE_SOCKETS:
            self._openSockets = {}  # key = remote listen address, value=IdleSocket
dataset/ETHPy150Open godaddy/Thespian/thespian/system/transport/TCPTransport.py/TCPTransport.__init__/original