Hello, newbie here, I'm having a problem with udp socket receiving a packet.
What exactly is wrong with these 2 functions? The packet is sent, but never received
Fucntion for receiving
bool SprejmiTest(unsigned short port)
{
sf::Packet PacketTest2;
sf::IpAddress IpEna;
unsigned short Port;
std::string Beseda;
sf::UdpSocket SocketServerTest;
SocketServerTest.setBlocking(0);
SocketServerTest.bind(port);
if(SocketServerTest.receive(PacketTest2,IpEna,Port)==sf::Socket::Done){
PacketTest2>>Beseda;
std::cout<<Beseda<<std::endl;
std::cout<<"Testni paket je sprejet"<<std::endl;
return true;}
else
return false;
}
Function for sending
bool PosljiTest(sf::IpAddress IpTest,unsigned short PortTest)
{
std::string Beseda="Zivjo";
sf::Packet PacketTest;
sf::UdpSocket SocketTest;
SocketTest.setBlocking(0);
PacketTest<<Beseda;
if(SocketTest.send(PacketTest,IpTest,PortTest)!=sf::Socket::Done){std::cout<<"Paket ni bil poslan";return false;}
std::cout<<"Paket poslan"<<std::endl;
return true;
}
Thank you!