2

I would like to use libev for a streaming server I am writing.

This is how everything is supposed to work:

  1. client opens a TCP socket connection to server
  2. server receives connection
  3. client sends a list of images they would like
  4. server reads request
  5. server loops through all of the images
    • server reads image from NAS
    • server processes image file meta data
    • server sends image data to client

I found sample code that allows me to read and write from the socket using libev I/O events (epoll under the hood). But, I am not sure how to handle the read from NAS and processing. This could take some time. And I don't want to block the server while this is happening.

Should this be done in another thread, and have the thread send the image data back to the client?

I was planning on using a thread pool. But, perhaps libev can support a processing step without blocking?

Any ideas or help would be greatly appreciated!

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
Jacko
  • 12,665
  • 18
  • 75
  • 126

1 Answers1

1

You'll need a file I/O library (such as Boost::ASIO) that supports asynchronous reads. The underlying APIs are aio_read, aio_suspend, lio_listio.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720