4

ENet is a UDP networking library, a tutorial is available here http://enet.bespin.org/Tutorial.html

What happens if I'm not calling enet_host_service() for some period of time, but packets arrive on the machine while I'm not "servicing" ? Are they buffered somewhere, awaiting a call to enet_host_service() ?

The tutorial also states I can call this function with 0 timeout, meaning if it doesn't wait, it has to read a buffer...

jokoon
  • 6,207
  • 11
  • 48
  • 85

1 Answers1

3

I am pretty sure the packets will buffer in the operating system until you call enet_host_service(), because until you do so, enet cannot do anything at all. It is totally dead, and its state does not change as long as your own code is running.

When you call enet_host_service(), it will use the socket API to retrieve the UDP packets from the OS, and then, they are probably buffered by enet itself (if there is more than one "event" or "packet"), since enet_host_service() allows you to handle one event at a time (while it may well receive multiple events from the OS's data).

So, you should call enet_host_service() as often as possible, because the OS will simply drop incoming packets when its buffer is full.

Realz Slaw
  • 3,138
  • 1
  • 24
  • 38
  • thanks, rocking as usual :) any way to know how many packets can the OS store ? does it depend on the ethernet chip ? – jokoon Nov 18 '12 at 16:46
  • @jokoon No I am not sure, but I think it depends on the OS, and might even be configurable. I don't think it depends on the ethernet chip, since UDP is a higher level than ethernet, though perhaps it too has some sort of buffer. See this [question](http://stackoverflow.com/q/1507475/586784) for some more info. – Realz Slaw Nov 18 '12 at 19:38