commit 119b2e8be1fa946f2e0c80fbc22134783e2ed29c Author: R. Tyler Croy Date: Sat Jan 9 13:45:40 2016 -0800 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c482540 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.sw +*.sw* +build/ +tmp/ diff --git a/build/.gitkeep b/build/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/pipeline.adb b/pipeline.adb new file mode 100644 index 0000000..ab5a2f9 --- /dev/null +++ b/pipeline.adb @@ -0,0 +1,72 @@ +-- +-- Pipeline demo with nanomsg +-- + +-- #include +-- #include +-- #include +-- #include +-- #include +-- +-- #define NODE0 "node0" +-- #define NODE1 "node1" +-- +-- int node0 (const char *url) +-- { +-- int sock = nn_socket (AF_SP, NN_PULL); +-- assert (sock >= 0); +-- assert (nn_bind (sock, url) >= 0); +-- while (1) +-- { +-- char *buf = NULL; +-- int bytes = nn_recv (sock, &buf, NN_MSG, 0); +-- assert (bytes >= 0); +-- printf ("NODE0: RECEIVED \"%s\"\n", buf); +-- nn_freemsg (buf); +-- } +-- } +-- +-- int node1 (const char *url, const char *msg) +-- { +-- int sz_msg = strlen (msg) + 1; // '\0' too +-- int sock = nn_socket (AF_SP, NN_PUSH); +-- assert (sock >= 0); +-- assert (nn_connect (sock, url) >= 0); +-- printf ("NODE1: SENDING \"%s\"\n", msg); +-- int bytes = nn_send (sock, msg, sz_msg, 0); +-- assert (bytes == sz_msg); +-- return nn_shutdown (sock, 0); +-- } +-- +-- int main (const int argc, const char **argv) +-- { +-- if (strncmp (NODE0, argv[1], strlen (NODE0)) == 0 && argc > 1) +-- return node0 (argv[2]); +-- else if (strncmp (NODE1, argv[1], strlen (NODE1)) == 0 && argc > 2) +-- return node1 (argv[2], argv[3]); +-- else +-- { +-- fprintf (stderr, "Usage: pipeline %s|%s ...'\n", +-- NODE0, NODE1); +-- return 1; +-- } +-- } + + +with Ada.Text_IO; +with nanomsg_nn_h; +use nanomsg_nn_h; +with Interfaces.C; +use Interfaces.C; + +procedure Pipeline is + pragma Linker_Options ("-lnanomsg"); + + NN_PROTO_PIPELINE : constant := 5; + NN_PULL : constant := (NN_PROTO_PIPELINE * 16 + 1); + + Socket : constant int := nn_socket (AF_SP, NN_PULL); +begin + + null; +end Pipeline;