SFML community forums
Help => Network => Topic started by: Guido_Ion on May 06, 2025, 12:35:22 am
-
I'm following the tutorial Communicating with sockets (https://www.sfml-dev.org/tutorials/3.0/network/socket/) for SFML 3.0 and I get this compiler error on the receive method
"no instance of overloaded function matches the argument list"
this is part of my code
#define IP 191, 168, 1, 50
#define PORT 54000
...
sf::UdpSocket socket;
sf::IpAddress sender(IP); // I had to add the IP here because it gave me an error if I left it like in the tutorial
std::uint16_t x;
std::string s;
double d;
sf::Packet packet;
packet >> x >> s >> d;
...
if (socket.receive(packet, sender, PORT) != sf::Socket::Status::Done)
{
// error
}
It won't tell me which is the incorrect argument, maybe it's the sender that is now sf::optional?
Was the tutorial 3.0 for networking not updated from 2.5?
I have some years of experience in C++ and SFML but I'm new to networking.
-
Looks like the tutorial wasn't properly updated.
You need to use a std::optional<sf::IpAddress> for the sender param.
See the example in the documentation: https://www.sfml-dev.org/documentation/3.0.1/classsf_1_1UdpSocket.html#details
-
That solved it, also the PORT was assumed int because I used #define, it should be an unsigned short so I created a variable, thanks!