nc -u
just sends data over UDP sockets. There's nothing particular about it, no specific protocol to follow: it's just raw data. You can simply send your messages through UDP sockets in C++ (see socket
with AF_INET, SOCK_DGRAM
parameters and other related functions).
But this means you miss a lot of syslog's features like facilities and priorities.
@Moose is right: the syslog
API is more relevant to your needs, since it is much more flexible (no need to modify your program if you want to change the behaviour, you'll only have to reconfigure the syslog daemon).