C linux multithreading networking

advertisements

I have a network application on a gateway. It receives and sends packets. For most of them, my gateway acts as a router, but in some cases, it can receive packets too.

Should I have:

  • only one main thread
  • a main thread + a dispatch thread in charge of giving it to the correct flow handler
  • as many threads as there are flows
  • something else.

?


Doing multithreading correctly is no simple matter, in many cases a select and friends based solution will be a whole lot easier to create.