Antonio Alvarado Hernández avatar Antonio Alvarado Hernández committed e14270d

Added `uReload`, a stuff to test `libuv` library

This is an incomplete example of using `libuv` from C code, based on
the from this presentation <http://vimeo.com/24713213&gt;.

Comments (0)

Files changed (2)

C++/uReload/Makefile

+# Makefile
+
+ureload : ureload.c
+	gcc -o ureload ureload.c
+
+# EOF

C++/uReload/ureload.c

+#include <stdio.h>
+
+#include "uv.h"
+
+int
+make_request() {
+	printf("Making request...\n");
+	return 0;
+}
+
+static uv_tcp_t server;
+
+int
+main (void) {
+
+	struct sockaddr_in address;
+	int rs;
+
+	/* always initializes */
+	uv_init();
+
+	/* set up some servers */
+	uv_tcp_init(&server, NULL, NULL);
+
+	address = uv_ip4_addr("0.0.0.0", 8888);
+	rs = uv_bind(&server, address);
+	if (rs) {
+		uv_err_t err = uv_last_error();
+		printf("bind: %s\n", uv_strerror(err);
+		return -1;
+	}
+	
+	rs = uv_listen(&server, 128, on_connect);
+	if (rs) {
+		uv_err_t err = uv_last_error();
+		printf("listen: %s\n", uv_strerror(err);
+		return -1;
+	}
+
+	/* run mainloop */
+	uv_run();
+	return 0;
+}
+
+/* EOF */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.