'WinSock connecting between two machines on different networks goes wrong C
I made a server/client program, everything works fine when I make a connection on the same network or on the same machine. This is however my problem: when I disconnect the client machine from the local network and connect it to another network(wifi) it doesn't connect to the server.
This is a part of my server:
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
res = getaddrinfo(NULL, PORT, &hints, &result);
Client:
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
res = getaddrinfo(SERVER_HOST, PORT, &hints, &result);
The destination port in my client code is the same port as the one in my server. I read somewhere that I have to buy a unique IP address? So my question is: How can I connect two computers on different networks using sockets in C (WinSock)?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
