Hey everyone,
I am new to all the networking thing. I did read the SFML-Tutorial about networking and watched some youtube videos, but none did answer my question:
Basically what I try to achieve: I have a server-side game loop, thats running like 30 times a second. In each of those Loops I want to poll and evaluate _every_ udp message that was send to me since the last polling. Messages can (but dont have to) be send from different clients/ips.
So I started by copy pasting the tutorial code:
void networkReceive() {
char data[100];
std::size_t received;
sf::IpAddress sender;
unsigned short port;
if (socket.receive(data, 100, received, sender, port) != sf::Socket::Done)
{
}
}
So here does some kind of polling happen, right? (I disabled blocking). Does that mean, that there is some kind of hardware/OS buffer, which stores the messages until I poll them? How long do they remain, if I dont poll them? And do they get deleted from there, once i polled them?
How can I find out, how many messages are left in the buffer? Is there some kind of getMessageNumber() function, so I can loop for each message in the buffer?
If there is no buffer, my whole idea about networking is wrong, isnt it? So I would need a thread that doesnt poll, but push the messages in an array? Is that kinda "best practice"?
I would really appreciate your help!