I have three process in three different computers.
Process 1, the client, asks Process 2 for the IP and PORT of Process 3.
Process 3 connected to Process 2 earlier, and Process 2 gets the IP of Process 3 from the file descriptor (Process 3 already knows the ip and port of Process 2).
This works fine, but if I try to run Process 2 and Process 3 in the same computer, the IP of Process 3 is always 127.0.0.1 so Process 1 never finds Process 3.
socklen_t len;
struct sockaddr_storage addr;
char ipstr[INET_ADDRSTRLEN];
len = sizeof addr;
getpeername(fd, (struct sockaddr*) &addr, &len);
struct sockaddr_in *s = (struct sockaddr_in *) &addr;
inet_ntop(AF_INET, &s->sin_addr, ipstr, sizeof ipstr);
This is the code I'm using, and ipstr is the IP I get.
How can I solve this?
Many thanks!