SFML community forums

Help => Network => Topic started by: diego997 on December 05, 2012, 10:39:26 pm

Title: Question about general princilple of sf::network behavour
Post by: diego997 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" ?
Title: Re: Question about general princilple of sf::network behavour
Post by: Laurent 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.
Title: Re: Question about general princilple of sf::network behavour
Post by: diego997 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
Title: Re: Question about general princilple of sf::network behavour
Post by: Laurent 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.