'Handle incoming SOCKS5 session request.'

def _handle_streamhost(self, iq):

    sid = iq['socks']['sid']
    if (not sid):
        raise XMPPError(etype='modify', condition='bad-request')
    if (not self._accept_stream(iq)):
        raise XMPPError(etype='modify', condition='not-acceptable')
    streamhosts = iq['socks']['streamhosts']
    conn = None
    used_streamhost = None
    sender = iq['from']
    for streamhost in streamhosts:
        try:
            conn = self._connect_proxy(sid, sender, self.xmpp.boundjid, streamhost['host'], streamhost['port'], peer=sender)
            used_streamhost = streamhost['jid']
            break
        except socket.error:
            continue
    else:
        raise XMPPError(etype='cancel', condition='item-not-found')
    iq.reply()
    with self._sessions_lock:
        self._sessions[sid] = conn
    iq['socks']['sid'] = sid
    iq['socks']['streamhost_used']['jid'] = used_streamhost
    iq.send()
    self.xmpp.event('socks5_stream', conn)
    self.xmpp.event(('stream:%s:%s' % (sid, conn.peer_jid)), conn)
