Convert to a proper network service

This commit is contained in:
R. Tyler Croy 2016-01-10 10:06:59 -08:00
parent 05fbfdbdc6
commit 17bc07787a
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
2 changed files with 8 additions and 10 deletions

View File

@ -10,7 +10,7 @@ clean:
check: all
./$(EXECUTABLE) & node0=\$! && sleep 1
./a.out node1 ipc:///tmp/pipeline.ipc "Hello, World" || true
./a.out node1 tcp://127.0.0.1:5019 "Hello, World" || true
generated: build/generated/nanomsg_nn_h.ads

View File

@ -14,14 +14,14 @@ with System,
use Ada.Text_IO;
with nanomsg_nn_h;
use nanomsg_nn_h;
use Interfaces.C,
Interfaces.C.Strings;
procedure Pipeline is
pragma Linker_Options ("-lnanomsg");
use nanomsg_nn_h;
use Interfaces.C,
Interfaces.C.Strings;
NN_PROTO_PIPELINE : constant := 5;
NN_PULL : constant := (NN_PROTO_PIPELINE * 16 + 1);
NN_MSG : constant := size_t'Last;
@ -33,7 +33,7 @@ begin
Put_Line ("Socket " & int'Image (Socket));
Status := nn_bind (Socket,
New_String ("ipc:///tmp/pipeline.ipc"));
New_String ("tcp://127.0.0.1:5019"));
Put_Line ("Status: " & int'Image (Socket));
@ -43,18 +43,16 @@ begin
begin
loop
Bytes := Integer (nn_recv (Socket, Buf, NN_MSG, 0));
Put_Line ("Recv " & Integer'Image (Bytes));
Flush;
declare
F : String (1 .. Bytes - 1);
pragma Import (C, F);
for F'Address use Buf;
begin
Put_Line (F);
Put ("Received" & Integer'Image (Bytes) & " bytes: ");
Put_Line ("""" & F & """");
end;
Status := nn_freemsg (Buf);
exit;
end loop;
end;