SFML community forums
Help => Network => Topic started by: blue_prawn on October 31, 2019, 10:53:23 pm
-
Hi,
I'm new to network programming, and I have a question related to the use of the .wait() method from a sf::SocketSelector object in this example:
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1SocketSelector.php
I read in the documentation that wait() is blocking, so I was wondering if it's possible to not call this function, and call directly .isReady() on my sockets.
Being a beginner with network programming and also with threads/concurrent/asynchrone programming I was wondering if I could start with a single thread and avoid blocking functions like wait()?
-
No, you can't. If you want non-blocking behavior, then put all your sockets in non-blocking mode and just test them separately; the purpose of the SocketSelector is to block on a set of sockets, so it's basically useless if you don't want to block ;)