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

Author Topic: How to handle Non-blocking TCP socket returning notready  (Read 5164 times)

0 Members and 1 Guest are viewing this topic.

Zoomulator

  • Newbie
  • *
  • Posts: 10
    • View Profile
How to handle Non-blocking TCP socket returning notready
« on: October 13, 2010, 11:14:44 pm »
I've set up a selector in the fashion stated in the tutorial though with non-blocking sockets. Occasionally, the receiving TCP socket will return "not ready" and then simply drop the packet.
It tries to read the socket twice and returns "Not ready" both times, and then it just stops trying so the packet is never received. The next packet may arrive properly as this only happens rarely.

What should I do when a TCP socket returns "not ready"? Should I put it in a special buffer that tries to read it again each iteration until it succeeds? What then if it doesn't succeed before another message arrives and is successfully received by the selector algorithm?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
How to handle Non-blocking TCP socket returning notready
« Reply #1 on: October 13, 2010, 11:46:43 pm »
You shouldn't use non-blocking sockets in a selector. It doesn't make sense, non-blocking sockets are supposed to be polled.
Laurent Gomila - SFML developer

Zoomulator

  • Newbie
  • *
  • Posts: 10
    • View Profile
How to handle Non-blocking TCP socket returning notready
« Reply #2 on: October 13, 2010, 11:49:05 pm »
I'm generally nonsensical =D

So when a selector says a socket is ready to receive, does it already have all data or is there still communications in the connection that could possibly delay the blocking?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
How to handle Non-blocking TCP socket returning notready
« Reply #3 on: October 14, 2010, 08:03:56 am »
Quote
So when a selector says a socket is ready to receive, does it already have all data or is there still communications in the connection that could possibly delay the blocking?

When the selector says a socket is ready, you can immediately call Receive and get data from it.
Laurent Gomila - SFML developer

Zoomulator

  • Newbie
  • *
  • Posts: 10
    • View Profile
How to handle Non-blocking TCP socket returning notready
« Reply #4 on: October 14, 2010, 12:23:47 pm »
Thanks Laurent!
Your support is impeccable!

 

anything