You are lucky Alan, i have spent almost a week now and still it doesn't work!
From the code you send me i understand that you also set the number of adress octets, well i suppose that is right.
What about the REPLY, if you look into jep0065 you'll see the following:
Example 18. Proxy Informs Initiator of Activation
<iq type='result'
from='proxy.host3'
to='initiator@host1/foo'
id='activate'/>
The Proxy MUST then send SOCKS5 acknowledgement of the connection to the Target.
Example 19. StreamHost Acknowledges Connection to Target
STATUS = X'00'
So, I suppose,according to Jep0065 the SOCKS5server wont sent the OK '00' REPLY to the CONNECT comamand to the Target untill the Initiator activates the stream,is that right?
So, being the Target, if i wait for a CONNECT reply from SOCKS5 server, in order to Send to the Initiator the StreamHost used, there will be a problem, beacuse i want ever get the CONNECT command, and i want ever sent the StreamHost used and the Initiaror want ever Activate the stream.
So, i have to send the StreamHost used before i sent the CONNECT command to the Proxy?
How do you handle this?