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[1] 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 ?
Code:
void* func(void* arg)
{
pthread_mutex_lock (&mutex);
Connect(address, port);
pthread_mutex_unlock (&mutex);
}
pthread_t thread;
int rc;
rc = pthread_create(&thread,NULL, func, NULL);
edit: but i still need a way to get address,so i can connect to it...How can i do that ?
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.