Hello. I wrote the simpliest client and serwer applications that can send a message. It works in local IP, but the same code wont work when I changed local IP to global IP. I have already tried to change internet connection, switch client<-> serwer, diffrent ports, but still nothing. Is my code wrong? Im the beginner with coding and I dont know internet structures well. I've already forward ports on my router and checked it works on program "port checker". Here is the code for client and serwer:
//serwer
#include <SFML\Network.hpp>
#include <iostream>
#include <conio.h>
using namespace sf;
using namespace std;
int main()
{
UdpSocket socket;
unsigned short s = 50001;
unsigned short k = 50002;
socket.bind(s);
string tmp = "";
Packet pakiet;
IpAddress ip_k = "89.66.209.51"; //can't work
//IpAddress ip_k = "192.168.0.12"; //works
socket.receive(pakiet, ip_k, k);
pakiet >> tmp;
cout << tmp;
getch();
}
//client
#include <SFML\Network.hpp>
#include <iostream>
#include <string>
#include <conio.h>
using namespace sf;
using namespace std;
int main()
{
UdpSocket socket;
unsigned short s = 50001;
unsigned short k = 50002;
socket.bind(k);
string tmp = "message";
Packet pakiet;
//IpAddress ip_s = "188.146.82.158"; //can't work
IpAddress ip_s = "192.168.0.12"; //works
pakiet << tmp;
socket.send(pakiet, ip_s, s);
getch();
}
btw. sorry for my english
------------------------------------------------------------------------------------------
edit: Found where is my problem. Im using udp sockets and trying to make a tcp connection
. Code has been repaired and it works now.