Part of the development team I work with has been given the challenge of writing a server for integration with our product. We have some low-level sensor devices that provide a C SDK, and we want to share them over a network for use by people collecting data. Sounds simple, right? Someone would connect a sensor device to their machine in one part of the building and run our server, thus sharing the device(s) with the rest of the network. Then a client would connect to that server via our application and collect sensor readings from the device.
I created a simple, language-agnostic network protocol, and a reference implementation in Java. The problem is creating an implementation that will work with our devices that only provide an SDK written in C. We were thinking of doing the following:
- Create polling threads that collect and store the most recent readings from each connected device.
- Use a multi-threaded server to spin off each incoming connection to a worker thread.
- When a worker thread receives a request for a sensor reading, the most recent value collected by the polling thread is sent back to the client.
That's a lot of threading, especially in C. So, to review, the general requirements are:
- Runs on Windows XP/Vista, Linux, and OS X machines
- Written in C or C++, to interact with the C SDK we have
- Accepts a variable number of simultaneous connections (worker threads)
- Must use threads, not forking (don't want to deal with another layer of IPC)
Can anyone suggest a library and preferably some example code to get use started?