I am trying to achieve peer to peer communication using winsock but gethostbyaddr
always return me NULL ,this thing works only on localhost, server_name is destination ip address
server_name="<--ipaddress-->"
struct sockaddr_in server;
addr = inet_addr(server_name);
cout<<"inet_addr(server_name) "<<addr<<endl;
hp = gethostbyaddr((char *)&addr, 4, AF_INET);
memset(&server, 0, sizeof(server));
memcpy(&(server.sin_addr), hp->h_addr, hp->h_length);
server.sin_family = hp->h_addrtype;
server.sin_port = htons(port);
conn_socket = socket(AF_INET, socket_type, 0);
connect(conn_socket, (struct sockaddr*)&server, sizeof(server))
We have already achieved p2p communication using python and it works perfectly fine on same port no and address .. thanks for any clue..
I do not have any idea how to do it in c++, in python we just used bind(---) , Can somebody show me code snippet how to achieve it.