Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: is "sf::SocketSelector .wait()" required?  (Read 4671 times)

0 Members and 1 Guest are viewing this topic.

blue_prawn

  • Newbie
  • *
  • Posts: 5
    • View Profile
is "sf::SocketSelector .wait()" required?
« 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()?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: is "sf::SocketSelector .wait()" required?
« Reply #1 on: November 01, 2019, 08:40:13 am »
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 ;)
Laurent Gomila - SFML developer

 

anything