I think i managed to resolved this in an easy way,the diferents betweend the second packet i receive and the one i send is that only the second byte is changed,in rest the packets are the same,so a only chnaged temp and resend it back,and it doesnt give me error anymore,it says is connected
About the thread thing: after the authentification i need to create a thread,and in the function thread to call connect between a mutex,something like that ?
edit: but i still need a way to get address,so i can connect to it...How can i do that ?
void* func(void* arg)
rc = pthread_create(&thread,NULL, func, NULL);
edit2: i resolved this too,the first 4 bytes are version/connection type/reserved/adress type(ip address,not domain) so i didnt checked to see if the address is an ip or domain name,it is ip(like in my case) then the next 4 bytes in the ip ,in my case(91-58-82-24) is the ip i was testing for a domain so thats why it take 91 as a lenght.