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

Author Topic: nonblocking sockets  (Read 2136 times)

0 Members and 1 Guest are viewing this topic.

Soul

  • Newbie
  • *
  • Posts: 44
    • View Profile
nonblocking sockets
« on: May 31, 2014, 04:45:38 pm »
Hey, i should use nonblocking sockets in my game to make her real-time, and my question, can i use selectors to make server multiclient? or better way is multithread with nonblocking sockets?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Soul

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: nonblocking sockets
« Reply #2 on: June 02, 2014, 04:11:01 pm »
okey, thanks for help, but atm i don't know how to use non-blocking sockets, with selector? or what..., i'm nerd in network programing, i make only simple ircbot and multichat with blockingsockets, but i don't want use threads in my game : D

Ninjaboi

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • http://www.ninjasoftcorp.webs.com/index.html
Re: nonblocking sockets
« Reply #3 on: June 02, 2014, 10:47:00 pm »
Quote
okey, thanks for help, but atm i don't know how to use non-blocking sockets

Sockets are set to block by default and have the function setBlocking() which allows you to toggle blocking.

sf::Socket socket;
socket.setBlocking(false);

Now instead of the socket waiting for when the action can and is performed, it will just return immediately thus preventing your thread from being halted. Check the detailed description of sf::Socket for a better explanation of blocking to non-blocking.

 

anything