For some reason i get wierd symbol on my small testprogram that waits for messages from my client. I'm trying to send sf::int32 value through a UdpSocket but on the serverside when i print the received message all that is being printed is weird symbols like smilies and such. What i tried was i took the sf::TcpSocket example that was in the documents and i just switched Tcp socket for Udp socket there. But for some reason I'm just getting weird data.
//Client
m_socket = new sf::UdpSocket();
m_socket->bind(3001);
sf::IpAddress address;
address = address.getLocalAddress();
//std::string message = "Hello there you server there!";
sf::Packet message;
sf::Int32 param1 = 10;
sf::Int32 param2 = 20;
sf::Int32 param3 = 40;
message << param1 << param2 << param3;
m_socket->send(message, address, 3000);
//Server
m_udpSocket.bind(3000);
while(true)
{
std::cout << "WAITING FOR MESSAGE" << std::endl;
sf::IpAddress sender;
unsigned short port;
sf::Packet receivedMessage;
m_udpSocket.receive(receivedMessage, sender, port);
sf::Int32 a, b, c;
if (receivedMessage >> a >> b >> c)
std::cout << sender.toString() << " said: " << a << b << c << std::endl;
};
}
What am I doing wrong? been searching on the forum but can't find a solution to this here problem..