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

Author Topic: Question about general princilple of sf::network behavour  (Read 2161 times)

0 Members and 1 Guest are viewing this topic.

diego997

  • Newbie
  • *
  • Posts: 21
    • View Profile
Question about general princilple of sf::network behavour
« on: December 05, 2012, 10:39:26 pm »
I have started reading about sf::Network and I have a question about general principle of send and receive.

While reach receive it waits for an answer, for instance I would like to create simple "chat", if so when I do not
writing anything on the keyboard, program should send for example "0" and all the time getting that "0" which means that I do not sending any text? I dont know if I well clarified the question, I want to know generaly how should it works, should it work dinamicly even if we do not touch the keyboard, send and receive should allways be "on the move" ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Question about general princilple of sf::network behavour
« Reply #1 on: December 05, 2012, 10:59:20 pm »
No. Why do you think it should? If you don't want the receive call to block your program, then either put it in a thread or set the socket as non-blocking.
Laurent Gomila - SFML developer

diego997

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Question about general princilple of sf::network behavour
« Reply #2 on: December 05, 2012, 11:09:40 pm »
Hmm what blocking and non-blocking mode is ? Is it explained in the tutorial ? Apology for that question

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Question about general princilple of sf::network behavour
« Reply #3 on: December 05, 2012, 11:22:27 pm »
It is indeed explained in the tutorial, but it is not online yet (for SFML 2.0 -- I don't remember about SFML 1.6) ;D

But you can read the API documentation.

Basically, when you set the socket as non-blocking, its functions return a special status (sf::Socket::NotReady) instead of blocking until something happens.
Laurent Gomila - SFML developer