1
Network / Problem with IP
« on: September 22, 2010, 03:00:10 pm »Quote from: "Mindiell"
So, can you try the SFML network samples ? Is this working ?
No
It's working only with "127.0.0.1", not "83.145.154.170".
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
So, can you try the SFML network samples ? Is this working ?
Have you a firewall ?
Can you modify the ports the modem let available ?
IPAddress ClientAddress;program use "255.255.255.255", not "83.145.154.170". Why? Someone can help me?
#include <SFML/Network.hpp>
#include <iostream>
int main()
{
const unsigned short Port = 2435;
sf::SocketUDP Server;
if (!Server.Bind(Port))
{
std::cout << " error" << std::endl;
}
sf::Packet Packet;
sf::IPAddress ClientAddress;
unsigned short ClientPort;
Server.Receive(Packet, ClientAddress, ClientPort);
int a;
Packet >> a;
std::cout << "packet : " << a << " from "<< ClientAddress <<" port: "<< ClientPort << std::endl;
a=12345;
Packet.Clear();
Packet << a;
Server.Send(Packet, ClientAddress, ClientPort);
std::cin.ignore(10000, '\n');
Server.Close();
return EXIT_SUCCESS;
}
#include <SFML/Network.hpp>
#include <iostream>
int main()
{
const unsigned short Port = 2400;
sf::SocketUDP Client;
if (!Client.Bind(Port))
{
std::cout << " error" << std::endl;
}
sf::Packet Packet;
sf::IPAddress ServerAddress;
unsigned short ServerPort=2435;
int a;
a=54321;
Packet << a;
Client.Send(Packet, ServerAddress, ServerPort);
Packet.Clear();
Client.Receive(Packet, ServerAddress, ServerPort);
Packet >> a;
std::cout << "packet : " << a << " from "<< ServerAddress <<" port: "<< ServerPort << std::endl;
std::cin.ignore(10000, '\n');
Client.Close();
return EXIT_SUCCESS;
}
IPAddress::GetPublicAddress();or
IPAddress Address("83.145.154.170");it doesn't work!
The use of sockets and packets is explained in the tutorials.
// With UDP sockets
Socket.Send(Packet, Address, Port);
Socket.Receive(Packet, Address);