I would like to use libev for a streaming server I am writing.
This is how everything is supposed to work:
- client opens a TCP socket connection to server
- server receives connection
- client sends a list of images they would like
- server reads request
- 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!