'Performs the process'

def get_inbound_port(self, desiredProtocol='TCP'):

    if (not self._forceReRun):
        remoteId = self._getRemoteId()
        saved_results = kb.kb.raw_read('extrusionScanner', 'extrusions')
        if (remoteId in saved_results):
            msg = 'Reusing    previous    result    from    the    knowledge    base:-    Selecting    port    "%s"    for    inbound    connections    from    the    compromised    server    to    w3af.'
            om.out.information((msg % saved_results[remoteId]))
            return saved_results[remoteId]
    om.out.information('Please    wait    some    seconds    while    w3af    performs    an    extrusion    scan.')
    es = extrusionServer(self._tcp_port_list, self._udp_port_list)
    if (not es.can_sniff()):
        msg = "The    user    running    w3af    can't    sniff    on    the    specified"
        msg += '    interface.    Hints:    Are    you    root?    Does    this    interface'
        msg += '    exist?'
        raise BaseFrameworkException(msg)
    else:
        (interpreter, remoteFilename) = self._sendExtrusionClient()
        sniff_thread = threading.Thread(target=es.sniff_and_analyze)
        sniff_thread.start()
        time.sleep(1)
        self._execExtrusionClient(interpreter, remoteFilename)
        res = es.get_result()
        om.out.information('Finished    extrusion    scan.')
        if (not res):
            msg = 'No    inbound    ports    have    been    found.    Maybe    the    extrusion'
            msg += '    scan    failed    ?'
            raise BaseFrameworkException(msg)
        else:
            host = res[0][0]
            msg = 'The    remote    host:    "%s"    can    connect    to    w3af    with    these    ports:'
            om.out.information((msg % host))
            port = None
            portList = []
            for x in res:
                if (x[0] == host):
                    port = x[1]
                    protocol = x[2]
                    om.out.information(((('-    ' + str(port)) + '/') + protocol))
                    portList.append((port, protocol))
            localPorts = []
            for (port, protocol) in portList:
                if self.is_available(port, protocol):
                    localPorts.append((port, protocol))
            if (not localPorts):
                raise BaseFrameworkException('All    the    inbound    ports    are    in    use.')
            else:
                msg = 'The    following    ports    are    not    bound    to    a    local    process'
                msg += '    and    can    be    used    by    w3af:'
                om.out.information(msg)
                for (lp, proto) in localPorts:
                    om.out.information(((('-    ' + str(lp)) + '/') + proto))
                    if (desiredProtocol.upper() == proto.upper()):
                        port = lp
                msg = 'Selecting    port    "%s/%s"    for    inbound    connections    from'
                msg += '    the    compromised    server    to    w3af.'
                om.out.information((msg % (port, proto)))
                if (not self._forceReRun):
                    om.out.debug('Saving    information    in    the    kb.')
                    saved_results = kb.kb.raw_read('extrusionScanner', 'extrusions')
                    if saved_results:
                        saved_results[remoteId] = port
                    else:
                        saved_results = {}
                        saved_results[remoteId] = port
                    kb.kb.raw_write('extrusionScanner', 'extrusions', saved_results)
                return port
