'This function is the main request handler function.
It delegates each step of the request processing to a different function and
handles raised exceptions in order to warn the client that its request has
been rejected (if needed).
The steps are:
- decode_request: reads the request and splits it into a dictionary. it checks
if the request is well-formed (
correct socks version, correct command number,
well-formed port number.
- validate_request: checks if the current configuration accepts to handle the
request (client identification, authorization rules)
- handle_connect: handles CONNECT requests
- handle_bind: handles BIND requests'

def handle(self, req):

    log.debug(thread.get_ident(), ('-' * 40))
    log.debug(thread.get_ident(), 'New    socks    connection    request    from    w3afAgentServer.')
    try:
        log.debug(thread.get_ident(), 'Decoded    request:', req)
        self.validate_socks4a(req)
        if (req['command'] == COMMAND_CONNECT):
            self.handle_connect(req)
        elif (req['command'] == COMMAND_BIND):
            self.handle_bind(req)
    except Request_Failed_No_Identd:
        self.answer_rejected(REQUEST_REJECTED_NO_IDENTD)
        log.error('Request', thread.get_ident(), 'failed,    no    identd.')
    except Request_Failed_Ident_failed:
        self.answer_rejected(REQUEST_REJECTED_IDENT_FAILED)
        log.error('Request', thread.get_ident(), 'failed,    ident    failed.')
    except Request_Error:
        self.answer_rejected()
        log.error('Request', thread.get_ident(), 'failed,    invalid    request.')
    except Remote_Connection_Failed:
        self.answer_rejected()
        log.error('Remote    connection    failed    while    processing    request', thread.get_ident())
    except Bind_TimeOut_Expired:
        self.answer_rejected()
        log.error('Bind    timeout    expired    while    processing    request', thread.get_ident())
    except Connection_Closed:
        pass
