libevent: c++
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 20 Nov 2016 20:40:30 +0100
changeset 412383ed4da507
parent 40 ba40af6cf815
child 42 5bd10c0ae650
libevent: c++
c++/domain-socket-bridge/domain-socket-bridge.c
c++/domain-socket-bridge/domain-socket-bridge.cpp
c++/domain-socket-bridge/nbproject/Makefile-Debug.mk
c++/domain-socket-bridge/nbproject/Makefile-Release.mk
c++/domain-socket-bridge/nbproject/configurations.xml
c++/domain-socket-bridge/nbproject/project.xml
     1.1 --- a/c++/domain-socket-bridge/domain-socket-bridge.c	Sun Nov 20 20:39:08 2016 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,224 +0,0 @@
     1.4 -#include <string.h>
     1.5 -#include <errno.h>
     1.6 -#include <stdio.h>
     1.7 -#include <signal.h>
     1.8 -#include <stdlib.h>
     1.9 -#include <string>
    1.10 -#include <regex>
    1.11 -
    1.12 -#include <event2/bufferevent.h>
    1.13 -#include <event2/buffer.h>
    1.14 -#include <event2/listener.h>
    1.15 -#include <event2/util.h>
    1.16 -#include <event2/event.h>
    1.17 -#include <sys/socket.h>
    1.18 -#include <sys/un.h>
    1.19 -#include <unistd.h>
    1.20 -
    1.21 -using namespace std;
    1.22 -
    1.23 -static const char MESSAGE[] = "Hello, World!\n";
    1.24 -
    1.25 -static const char PATH[] = "./roura";
    1.26 -
    1.27 -static const string COMMAND_EXIT("exit\n");
    1.28 -
    1.29 -static void listener_cb(evutil_socket_t, short, void *);
    1.30 -static void conn_read_cb(struct bufferevent *, void *);
    1.31 -static void conn_write_cb(struct bufferevent *, void *);
    1.32 -static void conn_event_cb(struct bufferevent *, short, void *);
    1.33 -static void signal_cb(evutil_socket_t, short, void *);
    1.34 -static void print_socket_info(int, int);
    1.35 -
    1.36 -int main(int argc, char **argv) {
    1.37 -	printf("%4s %8s\n", "*", "STARTED");
    1.38 -	struct event_base *base;
    1.39 -	evutil_socket_t listener;
    1.40 -	struct event *listener_event;
    1.41 -	struct event *signal_event;
    1.42 -
    1.43 -	struct sockaddr_un sun;
    1.44 -
    1.45 -	setvbuf(stdout, NULL, _IONBF, 0);
    1.46 -
    1.47 -	base = event_base_new();
    1.48 -	if (!base) {
    1.49 -		printf("%4s %8s %s\n", "*", "ERROR", "unable to initialize libevent");
    1.50 -		return 1;
    1.51 -	}
    1.52 -
    1.53 -	memset(&sun, 0, sizeof (sun));
    1.54 -	sun.sun_family = AF_UNIX;
    1.55 -	strcpy(sun.sun_path, PATH);
    1.56 -
    1.57 -	listener = socket(AF_UNIX, SOCK_STREAM, 0);
    1.58 -	evutil_make_socket_nonblocking(listener);
    1.59 -
    1.60 -	if (bind(listener, (struct sockaddr*) &sun, sizeof (sun)) < 0) {
    1.61 -		printf("%4s %8s %s: %s\n", "*", "ERROR", "unable to create domain socket:", PATH);
    1.62 -		return 1;
    1.63 -	}
    1.64 -
    1.65 -	if (listen(listener, 16) < 0) {
    1.66 -		printf("%4s %8s %s\n", "*", "ERROR", "unable to listen");
    1.67 -		return 1;
    1.68 -	}
    1.69 -
    1.70 -	// identifikátor serverového soketu (v současnosti číslo FD)
    1.71 -	printf("%4s %8s listening at: sun_path = %s → socketId = %d\n", "*", "SOCKET", sun.sun_path, listener);
    1.72 -
    1.73 -	listener_event = event_new(base, listener, EV_READ | EV_PERSIST, listener_cb, (void*) base);
    1.74 -
    1.75 -	if (!listener_event) {
    1.76 -		printf("%4s %8s %s\n", "*", "ERROR", "unable to do event_new()");
    1.77 -		return 1;
    1.78 -	}
    1.79 -
    1.80 -	event_add(listener_event, NULL);
    1.81 -
    1.82 -	signal_event = evsignal_new(base, SIGINT, signal_cb, (void *) base);
    1.83 -
    1.84 -	if (!signal_event || event_add(signal_event, NULL) < 0) {
    1.85 -		printf("%4s %8s %s\n", "*", "ERROR", "unable to create/add a signal event");
    1.86 -		return 1;
    1.87 -	}
    1.88 -
    1.89 -	event_base_dispatch(base);
    1.90 -
    1.91 -	event_free(listener_event);
    1.92 -	event_free(signal_event);
    1.93 -	event_base_free(base);
    1.94 -
    1.95 -	// smažeme soket na disku / soubor -- jinak by program příště spadl na bind()
    1.96 -	// TODO: co když soket někdo přesune a místo něj dá jiný soubor?
    1.97 -	unlink(PATH);
    1.98 -
    1.99 -	printf("%4s %8s\n", "*", "FINISHED");
   1.100 -	return 0;
   1.101 -}
   1.102 -
   1.103 -static void listener_cb(evutil_socket_t listener, short event, void *user_data) {
   1.104 -	struct event_base *base = (event_base *) user_data;
   1.105 -	struct bufferevent *bev;
   1.106 -
   1.107 -	struct sockaddr_storage ss;
   1.108 -	socklen_t slen = sizeof (ss);
   1.109 -	int fd = accept(listener, (struct sockaddr*) &ss, &slen);
   1.110 -
   1.111 -	// identifikátor navázaného spojení (v současnosti číslo FD)
   1.112 -	int * connectionId = (int*) malloc(sizeof (fd));
   1.113 -	*connectionId = fd;
   1.114 -
   1.115 -	if (fd < 0) {
   1.116 -		printf("%4d %8s %s\n", *connectionId, "ERROR", "unable to accept()");
   1.117 -		return;
   1.118 -	} else if (fd > FD_SETSIZE) {
   1.119 -		// FD_SETSIZE = 1024 -- Proč? Co když bude spojení víc?
   1.120 -		printf("%4d %8s fd (%d) > FD_SETSIZE (%d)\n", *connectionId, "ERROR", fd, FD_SETSIZE);
   1.121 -		close(fd);
   1.122 -		return;
   1.123 -	}
   1.124 -
   1.125 -	evutil_make_socket_nonblocking(fd);
   1.126 -
   1.127 -
   1.128 -	bev = bufferevent_socket_new(base, fd, BEV_OPT_CLOSE_ON_FREE);
   1.129 -	if (!bev) {
   1.130 -		printf("%4d %8s %s\n", *connectionId, "ERROR", "constructing bufferevent");
   1.131 -		event_base_loopbreak(base);
   1.132 -		return;
   1.133 -	}
   1.134 -
   1.135 -
   1.136 -
   1.137 -
   1.138 -	bufferevent_setcb(bev, conn_read_cb, conn_write_cb, conn_event_cb, (void*) connectionId);
   1.139 -	bufferevent_enable(bev, EV_READ | EV_WRITE);
   1.140 -
   1.141 -	printf("%4d %8s somebody has connected: socketId = %d → connectionId = %d\n", *connectionId, "CONN", listener, *connectionId);
   1.142 -	print_socket_info(*connectionId, fd);
   1.143 -
   1.144 -	bufferevent_write(bev, MESSAGE, strlen(MESSAGE));
   1.145 -}
   1.146 -
   1.147 -static void conn_read_cb(struct bufferevent *bev, void *user_data) {
   1.148 -	int connectionId = *((int*) user_data);
   1.149 -
   1.150 -	/* This callback is invoked when there is data to read on bev. */
   1.151 -	struct evbuffer *input = bufferevent_get_input(bev);
   1.152 -	struct evbuffer *output = bufferevent_get_output(bev);
   1.153 -	struct event_base *base = bufferevent_get_base(bev);
   1.154 -
   1.155 -	size_t len = evbuffer_get_length(input);
   1.156 -	char *data = (char*) malloc(len);
   1.157 -	evbuffer_copyout(input, data, len);
   1.158 -
   1.159 -
   1.160 -	string dataFormated(data);
   1.161 -	dataFormated = regex_replace(dataFormated, regex("\\n"), "\\n");
   1.162 -	printf("%4d %8s '%s'\n", connectionId, "IN", dataFormated.c_str());
   1.163 -
   1.164 -	if (COMMAND_EXIT.compare(data) == 0) {
   1.165 -		struct timeval delay = {2, 123};
   1.166 -		printf("%4d %8s client asks us to terminate; finishing in %ld sesonds and %ld microseconds\n", connectionId, "EXIT", delay.tv_sec, delay.tv_usec);
   1.167 -		event_base_loopexit(base, &delay);
   1.168 -	}
   1.169 -
   1.170 -	evbuffer_add(output, "echo: ", 6);
   1.171 -	/* Copy all the data from the input buffer to the output buffer. */
   1.172 -	evbuffer_add_buffer(output, input);
   1.173 -	free(data);
   1.174 -}
   1.175 -
   1.176 -static void conn_write_cb(struct bufferevent *bev, void *user_data) {
   1.177 -	int connectionId = *((int*) user_data);
   1.178 -
   1.179 -	struct evbuffer *output = bufferevent_get_output(bev);
   1.180 -	if (evbuffer_get_length(output) == 0) {
   1.181 -		printf("%4d %8s\n", connectionId, "FLUSH");
   1.182 -		/* nebudeme ukončovat spojení
   1.183 -		bufferevent_free(bev);
   1.184 -		 */
   1.185 -	} else {
   1.186 -		// FIXME: sem to nikdy nepřijde
   1.187 -		size_t len = evbuffer_get_length(output);
   1.188 -		char *data = (char*) malloc(len);
   1.189 -		evbuffer_copyout(output, data, len);
   1.190 -		printf("%4d %8s '%s'\n", connectionId, "OUT", data);
   1.191 -		free(data);
   1.192 -	}
   1.193 -}
   1.194 -
   1.195 -static void conn_event_cb(struct bufferevent *bev, short events, void *user_data) {
   1.196 -	int connectionId = *((int*) user_data);
   1.197 -
   1.198 -	if (events & BEV_EVENT_EOF) {
   1.199 -		printf("%4d %8s\n", connectionId, "CLOSE");
   1.200 -	} else if (events & BEV_EVENT_ERROR) {
   1.201 -		printf("%4d %8s %s\n", connectionId, "ERROR", strerror(errno));
   1.202 -	} else {
   1.203 -		printf("%4d %8s\n", connectionId, "OTHER");
   1.204 -		// None of the other events can happen here, since we haven't enabled timeouts
   1.205 -	}
   1.206 -
   1.207 -	bufferevent_free(bev);
   1.208 -	free(user_data);
   1.209 -}
   1.210 -
   1.211 -static void signal_cb(evutil_socket_t sig, short events, void *user_data) {
   1.212 -	struct event_base *base = (event_base *) user_data;
   1.213 -	struct timeval delay = {2, 123};
   1.214 -
   1.215 -	printf("\n%4s %8s got SIGINT (Ctrl+C); finishing in %ld sesonds and %ld microseconds\n", "*", "SIGNAL", delay.tv_sec, delay.tv_usec);
   1.216 -
   1.217 -	event_base_loopexit(base, &delay);
   1.218 -}
   1.219 -
   1.220 -static void print_socket_info(int connectionId, int fd) {
   1.221 -	struct ucred cr;
   1.222 -	unsigned int cl = sizeof (cr);
   1.223 -
   1.224 -	if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl) == 0) {
   1.225 -		printf("%4d %8s client identification: pid=%d, uid=%d, gid=%d\n", connectionId, "CONN", cr.pid, cr.uid, cr.gid);
   1.226 -	}
   1.227 -}
   1.228 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/c++/domain-socket-bridge/domain-socket-bridge.cpp	Sun Nov 20 20:40:30 2016 +0100
     2.3 @@ -0,0 +1,224 @@
     2.4 +#include <string.h>
     2.5 +#include <errno.h>
     2.6 +#include <stdio.h>
     2.7 +#include <signal.h>
     2.8 +#include <stdlib.h>
     2.9 +#include <string>
    2.10 +#include <regex>
    2.11 +
    2.12 +#include <event2/bufferevent.h>
    2.13 +#include <event2/buffer.h>
    2.14 +#include <event2/listener.h>
    2.15 +#include <event2/util.h>
    2.16 +#include <event2/event.h>
    2.17 +#include <sys/socket.h>
    2.18 +#include <sys/un.h>
    2.19 +#include <unistd.h>
    2.20 +
    2.21 +using namespace std;
    2.22 +
    2.23 +static const char MESSAGE[] = "Hello, World!\n";
    2.24 +
    2.25 +static const char PATH[] = "./roura";
    2.26 +
    2.27 +static const string COMMAND_EXIT("exit\n");
    2.28 +
    2.29 +static void listener_cb(evutil_socket_t, short, void *);
    2.30 +static void conn_read_cb(struct bufferevent *, void *);
    2.31 +static void conn_write_cb(struct bufferevent *, void *);
    2.32 +static void conn_event_cb(struct bufferevent *, short, void *);
    2.33 +static void signal_cb(evutil_socket_t, short, void *);
    2.34 +static void print_socket_info(int, int);
    2.35 +
    2.36 +int main(int argc, char **argv) {
    2.37 +	printf("%4s %8s\n", "*", "STARTED");
    2.38 +	struct event_base *base;
    2.39 +	evutil_socket_t listener;
    2.40 +	struct event *listener_event;
    2.41 +	struct event *signal_event;
    2.42 +
    2.43 +	struct sockaddr_un sun;
    2.44 +
    2.45 +	setvbuf(stdout, NULL, _IONBF, 0);
    2.46 +
    2.47 +	base = event_base_new();
    2.48 +	if (!base) {
    2.49 +		printf("%4s %8s %s\n", "*", "ERROR", "unable to initialize libevent");
    2.50 +		return 1;
    2.51 +	}
    2.52 +
    2.53 +	memset(&sun, 0, sizeof (sun));
    2.54 +	sun.sun_family = AF_UNIX;
    2.55 +	strcpy(sun.sun_path, PATH);
    2.56 +
    2.57 +	listener = socket(AF_UNIX, SOCK_STREAM, 0);
    2.58 +	evutil_make_socket_nonblocking(listener);
    2.59 +
    2.60 +	if (bind(listener, (struct sockaddr*) &sun, sizeof (sun)) < 0) {
    2.61 +		printf("%4s %8s %s: %s\n", "*", "ERROR", "unable to create domain socket:", PATH);
    2.62 +		return 1;
    2.63 +	}
    2.64 +
    2.65 +	if (listen(listener, 16) < 0) {
    2.66 +		printf("%4s %8s %s\n", "*", "ERROR", "unable to listen");
    2.67 +		return 1;
    2.68 +	}
    2.69 +
    2.70 +	// identifikátor serverového soketu (v současnosti číslo FD)
    2.71 +	printf("%4s %8s listening at: sun_path = %s → socketId = %d\n", "*", "SOCKET", sun.sun_path, listener);
    2.72 +
    2.73 +	listener_event = event_new(base, listener, EV_READ | EV_PERSIST, listener_cb, (void*) base);
    2.74 +
    2.75 +	if (!listener_event) {
    2.76 +		printf("%4s %8s %s\n", "*", "ERROR", "unable to do event_new()");
    2.77 +		return 1;
    2.78 +	}
    2.79 +
    2.80 +	event_add(listener_event, NULL);
    2.81 +
    2.82 +	signal_event = evsignal_new(base, SIGINT, signal_cb, (void *) base);
    2.83 +
    2.84 +	if (!signal_event || event_add(signal_event, NULL) < 0) {
    2.85 +		printf("%4s %8s %s\n", "*", "ERROR", "unable to create/add a signal event");
    2.86 +		return 1;
    2.87 +	}
    2.88 +
    2.89 +	event_base_dispatch(base);
    2.90 +
    2.91 +	event_free(listener_event);
    2.92 +	event_free(signal_event);
    2.93 +	event_base_free(base);
    2.94 +
    2.95 +	// smažeme soket na disku / soubor -- jinak by program příště spadl na bind()
    2.96 +	// TODO: co když soket někdo přesune a místo něj dá jiný soubor?
    2.97 +	unlink(PATH);
    2.98 +
    2.99 +	printf("%4s %8s\n", "*", "FINISHED");
   2.100 +	return 0;
   2.101 +}
   2.102 +
   2.103 +static void listener_cb(evutil_socket_t listener, short event, void *user_data) {
   2.104 +	struct event_base *base = (event_base *) user_data;
   2.105 +	struct bufferevent *bev;
   2.106 +
   2.107 +	struct sockaddr_storage ss;
   2.108 +	socklen_t slen = sizeof (ss);
   2.109 +	int fd = accept(listener, (struct sockaddr*) &ss, &slen);
   2.110 +
   2.111 +	// identifikátor navázaného spojení (v současnosti číslo FD)
   2.112 +	int * connectionId = (int*) malloc(sizeof (fd));
   2.113 +	*connectionId = fd;
   2.114 +
   2.115 +	if (fd < 0) {
   2.116 +		printf("%4d %8s %s\n", *connectionId, "ERROR", "unable to accept()");
   2.117 +		return;
   2.118 +	} else if (fd > FD_SETSIZE) {
   2.119 +		// FD_SETSIZE = 1024 -- Proč? Co když bude spojení víc?
   2.120 +		printf("%4d %8s fd (%d) > FD_SETSIZE (%d)\n", *connectionId, "ERROR", fd, FD_SETSIZE);
   2.121 +		close(fd);
   2.122 +		return;
   2.123 +	}
   2.124 +
   2.125 +	evutil_make_socket_nonblocking(fd);
   2.126 +
   2.127 +
   2.128 +	bev = bufferevent_socket_new(base, fd, BEV_OPT_CLOSE_ON_FREE);
   2.129 +	if (!bev) {
   2.130 +		printf("%4d %8s %s\n", *connectionId, "ERROR", "constructing bufferevent");
   2.131 +		event_base_loopbreak(base);
   2.132 +		return;
   2.133 +	}
   2.134 +
   2.135 +
   2.136 +
   2.137 +
   2.138 +	bufferevent_setcb(bev, conn_read_cb, conn_write_cb, conn_event_cb, (void*) connectionId);
   2.139 +	bufferevent_enable(bev, EV_READ | EV_WRITE);
   2.140 +
   2.141 +	printf("%4d %8s somebody has connected: socketId = %d → connectionId = %d\n", *connectionId, "CONN", listener, *connectionId);
   2.142 +	print_socket_info(*connectionId, fd);
   2.143 +
   2.144 +	bufferevent_write(bev, MESSAGE, strlen(MESSAGE));
   2.145 +}
   2.146 +
   2.147 +static void conn_read_cb(struct bufferevent *bev, void *user_data) {
   2.148 +	int connectionId = *((int*) user_data);
   2.149 +
   2.150 +	/* This callback is invoked when there is data to read on bev. */
   2.151 +	struct evbuffer *input = bufferevent_get_input(bev);
   2.152 +	struct evbuffer *output = bufferevent_get_output(bev);
   2.153 +	struct event_base *base = bufferevent_get_base(bev);
   2.154 +
   2.155 +	size_t len = evbuffer_get_length(input);
   2.156 +	char *data = (char*) malloc(len);
   2.157 +	evbuffer_copyout(input, data, len);
   2.158 +
   2.159 +
   2.160 +	string dataFormated(data);
   2.161 +	dataFormated = regex_replace(dataFormated, regex("\\n"), "\\n");
   2.162 +	printf("%4d %8s '%s'\n", connectionId, "IN", dataFormated.c_str());
   2.163 +
   2.164 +	if (COMMAND_EXIT.compare(data) == 0) {
   2.165 +		struct timeval delay = {2, 123};
   2.166 +		printf("%4d %8s client asks us to terminate; finishing in %ld sesonds and %ld microseconds\n", connectionId, "EXIT", delay.tv_sec, delay.tv_usec);
   2.167 +		event_base_loopexit(base, &delay);
   2.168 +	}
   2.169 +
   2.170 +	evbuffer_add(output, "echo: ", 6);
   2.171 +	/* Copy all the data from the input buffer to the output buffer. */
   2.172 +	evbuffer_add_buffer(output, input);
   2.173 +	free(data);
   2.174 +}
   2.175 +
   2.176 +static void conn_write_cb(struct bufferevent *bev, void *user_data) {
   2.177 +	int connectionId = *((int*) user_data);
   2.178 +
   2.179 +	struct evbuffer *output = bufferevent_get_output(bev);
   2.180 +	if (evbuffer_get_length(output) == 0) {
   2.181 +		printf("%4d %8s\n", connectionId, "FLUSH");
   2.182 +		/* nebudeme ukončovat spojení
   2.183 +		bufferevent_free(bev);
   2.184 +		 */
   2.185 +	} else {
   2.186 +		// FIXME: sem to nikdy nepřijde
   2.187 +		size_t len = evbuffer_get_length(output);
   2.188 +		char *data = (char*) malloc(len);
   2.189 +		evbuffer_copyout(output, data, len);
   2.190 +		printf("%4d %8s '%s'\n", connectionId, "OUT", data);
   2.191 +		free(data);
   2.192 +	}
   2.193 +}
   2.194 +
   2.195 +static void conn_event_cb(struct bufferevent *bev, short events, void *user_data) {
   2.196 +	int connectionId = *((int*) user_data);
   2.197 +
   2.198 +	if (events & BEV_EVENT_EOF) {
   2.199 +		printf("%4d %8s\n", connectionId, "CLOSE");
   2.200 +	} else if (events & BEV_EVENT_ERROR) {
   2.201 +		printf("%4d %8s %s\n", connectionId, "ERROR", strerror(errno));
   2.202 +	} else {
   2.203 +		printf("%4d %8s\n", connectionId, "OTHER");
   2.204 +		// None of the other events can happen here, since we haven't enabled timeouts
   2.205 +	}
   2.206 +
   2.207 +	bufferevent_free(bev);
   2.208 +	free(user_data);
   2.209 +}
   2.210 +
   2.211 +static void signal_cb(evutil_socket_t sig, short events, void *user_data) {
   2.212 +	struct event_base *base = (event_base *) user_data;
   2.213 +	struct timeval delay = {2, 123};
   2.214 +
   2.215 +	printf("\n%4s %8s got SIGINT (Ctrl+C); finishing in %ld sesonds and %ld microseconds\n", "*", "SIGNAL", delay.tv_sec, delay.tv_usec);
   2.216 +
   2.217 +	event_base_loopexit(base, &delay);
   2.218 +}
   2.219 +
   2.220 +static void print_socket_info(int connectionId, int fd) {
   2.221 +	struct ucred cr;
   2.222 +	unsigned int cl = sizeof (cr);
   2.223 +
   2.224 +	if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl) == 0) {
   2.225 +		printf("%4d %8s client identification: pid=%d, uid=%d, gid=%d\n", connectionId, "CONN", cr.pid, cr.uid, cr.gid);
   2.226 +	}
   2.227 +}
   2.228 \ No newline at end of file
     3.1 --- a/c++/domain-socket-bridge/nbproject/Makefile-Debug.mk	Sun Nov 20 20:39:08 2016 +0100
     3.2 +++ b/c++/domain-socket-bridge/nbproject/Makefile-Debug.mk	Sun Nov 20 20:40:30 2016 +0100
     3.3 @@ -62,10 +62,10 @@
     3.4  	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
     3.5  	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/domain-socket-bridge ${OBJECTFILES} ${LDLIBSOPTIONS}
     3.6  
     3.7 -${OBJECTDIR}/domain-socket-bridge.o: domain-socket-bridge.c 
     3.8 +${OBJECTDIR}/domain-socket-bridge.o: domain-socket-bridge.cpp 
     3.9  	${MKDIR} -p ${OBJECTDIR}
    3.10  	${RM} "$@.d"
    3.11 -	$(COMPILE.cc) -g `pkg-config --cflags libevent` -std=c++11  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/domain-socket-bridge.o domain-socket-bridge.c
    3.12 +	$(COMPILE.cc) -g `pkg-config --cflags libevent` -std=c++11  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/domain-socket-bridge.o domain-socket-bridge.cpp
    3.13  
    3.14  # Subprojects
    3.15  .build-subprojects:
     4.1 --- a/c++/domain-socket-bridge/nbproject/Makefile-Release.mk	Sun Nov 20 20:39:08 2016 +0100
     4.2 +++ b/c++/domain-socket-bridge/nbproject/Makefile-Release.mk	Sun Nov 20 20:40:30 2016 +0100
     4.3 @@ -62,10 +62,10 @@
     4.4  	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
     4.5  	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/domain-socket-bridge ${OBJECTFILES} ${LDLIBSOPTIONS}
     4.6  
     4.7 -${OBJECTDIR}/domain-socket-bridge.o: domain-socket-bridge.c 
     4.8 +${OBJECTDIR}/domain-socket-bridge.o: domain-socket-bridge.cpp 
     4.9  	${MKDIR} -p ${OBJECTDIR}
    4.10  	${RM} "$@.d"
    4.11 -	$(COMPILE.cc) -O2 `pkg-config --cflags libevent` -std=c++11  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/domain-socket-bridge.o domain-socket-bridge.c
    4.12 +	$(COMPILE.cc) -O2 `pkg-config --cflags libevent` -std=c++11  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/domain-socket-bridge.o domain-socket-bridge.cpp
    4.13  
    4.14  # Subprojects
    4.15  .build-subprojects:
     5.1 --- a/c++/domain-socket-bridge/nbproject/configurations.xml	Sun Nov 20 20:39:08 2016 +0100
     5.2 +++ b/c++/domain-socket-bridge/nbproject/configurations.xml	Sun Nov 20 20:40:30 2016 +0100
     5.3 @@ -12,7 +12,7 @@
     5.4      <logicalFolder name="SourceFiles"
     5.5                     displayName="Source Files"
     5.6                     projectFiles="true">
     5.7 -      <itemPath>domain-socket-bridge.c</itemPath>
     5.8 +      <itemPath>domain-socket-bridge.cpp</itemPath>
     5.9      </logicalFolder>
    5.10      <logicalFolder name="TestFiles"
    5.11                     displayName="Test Files"
    5.12 @@ -44,7 +44,7 @@
    5.13            </linkerLibItems>
    5.14          </linkerTool>
    5.15        </compileType>
    5.16 -      <item path="domain-socket-bridge.c" ex="false" tool="1" flavor2="0">
    5.17 +      <item path="domain-socket-bridge.cpp" ex="false" tool="1" flavor2="0">
    5.18        </item>
    5.19      </conf>
    5.20      <conf name="Release" type="1">
    5.21 @@ -73,7 +73,7 @@
    5.22            </linkerLibItems>
    5.23          </linkerTool>
    5.24        </compileType>
    5.25 -      <item path="domain-socket-bridge.c" ex="false" tool="1" flavor2="0">
    5.26 +      <item path="domain-socket-bridge.cpp" ex="false" tool="1" flavor2="0">
    5.27        </item>
    5.28      </conf>
    5.29    </confs>
     6.1 --- a/c++/domain-socket-bridge/nbproject/project.xml	Sun Nov 20 20:39:08 2016 +0100
     6.2 +++ b/c++/domain-socket-bridge/nbproject/project.xml	Sun Nov 20 20:40:30 2016 +0100
     6.3 @@ -4,8 +4,8 @@
     6.4      <configuration>
     6.5          <data xmlns="http://www.netbeans.org/ns/make-project/1">
     6.6              <name>domain-socket-bridge</name>
     6.7 -            <c-extensions>c</c-extensions>
     6.8 -            <cpp-extensions/>
     6.9 +            <c-extensions/>
    6.10 +            <cpp-extensions>cpp</cpp-extensions>
    6.11              <header-extensions/>
    6.12              <sourceEncoding>UTF-8</sourceEncoding>
    6.13              <make-dep-projects/>