This code recreates the problem (:
#include <SFML/Network.hpp>
#include <iostream>
void Receive();
sf::SocketUDP Socket;
int main()
{
std::cout << "Send or receive (0/1): ";
int choice;
std::cin >> choice;
if (choice == 1)
{
Socket.Bind(4639);
Socket.SetBlocking(false);
while (true)
{
Receive();
}
}
else
{
while (true)
{
sf::Packet Packet;
Packet << 1;
Socket.Send(Packet, "localhost", 4639);
}
}
return EXIT_SUCCESS;
}
void Receive()
{
sf::Packet Packet;
sf::IPAddress IP;
unsigned short port;
Socket.Receive(Packet, IP, port);
if (IP != "255.255.255.255")
{
int PType = -1;
Packet >> PType;
if (PType == -1)
{
std::cout << "Bad Packet!" << std::endl;
}
std::cout << "Packet received! IP: " << IP << " Port: " << port << " Packet Type: " << PType << std::endl;
}
}