views:

360

answers:

4

I wonder what library would ease the development of a cross-platform service/daemon ? (C/C++)

I'm targeting: Windows, Linux and OS X. Requirements: network operations and serial port communication.

Also it would be nice to have a basic sample service application.

+4  A: 

A daemon in Linux is really just a process that runs disconnected from a terminal. In Windows, a service is something that can be controlled using the service management API, but once again is basically just a disconnected process. The disconnection aside, daemons & servers don't have much in common, from task to task. There is no requirement, for example, that they be multi-threaded, be asynchronous or perform network I/O. Given that, it's kind of hard to see what a cross-platform library would do.

anon
+3  A: 

Boost probably has most of what you need in terms of threading and networking I/O.

You may also find Qt a good alternative. It also has threading and networking libraries and has a much easier to use & understand event-driven programming model using a run loop. Qt's signal/slot system is very easy to use and ideal for a network daemon/service (Boost also includes a signal/slot system but it is harder to use and does not include an event loop; you have to roll your own using some event library). As a cross-platform library, Qt can handle many of the issues in bridging the Unix (OS X and Linux) vs. Windows mental model for processes, filesystems, etc.

For unit testing, I've been very happy with Google's C++ unit testing library called googletest (though both Boost and Qt also have built-in unit testing systems). It runs on all the platforms you specify. I've done a lot of work with googletest on cross-platform Qt projects and found it quite satisfactory.

Barry Wark
+5  A: 

You should take a look POCO. Depending on what you are doing it could have facilities to do a large amount of the work for you with a lot less work than Boost.

An obligatory mention for ACE though I don't personally care for it much.

Duck
+2  A: 

Hi,

When it comes to Qt u might try:

http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Utilities/qtservice/

U'll find there some examples

aleksandar sasha babic