mesytec-mnode/demo/raw/README.adoc

65 lines
1.7 KiB
Text
Raw Normal View History

= raw
This is a simple asynchronous demo, that demonstrates use of the RAW
sockets with a server, along with async message handling, to obtain a
very high level of asynchronous operation, suitable for use in a highly
concurrent server application.
== Compiling
You can override the level of concurrency with the `PARALLEL` option.
This determines how many requests the server will accept
at a time, and keep outstanding. Note that for our toy
implementation, we create this many "logical" flows of execution
(these are _NOT_ threads), where a request is followed by a reply.
The value of `PARALLEL` must be at least one, and may be as large
as your memory will permit. (The default value is 32.)
The best way to build is using cmake and Ninja build:
[source, bash]
----
% mkdir build
% cd build
% cmake -G Ninja ..
% ninja
----
You can also build the hard way. For example, on UNIX-style systems:
[source, bash]
----
% export CPPFLAGS="-D PARALLEL=32 -I /usr/local/include"
% export LDFLAGS="-L /usr/local/lib -lnng"
% export CC="cc"
% ${CC} ${CPPFLAGS} raw.c -o raw ${LDFLAGS}
----
== Running
To run the server, use the arguments `__url__ -s`.
To run the client, use the arguments `__url__ __msec__`.
The _msec_ is a "delay" time that server will wait before responding.
We have these delays so simulate long running work.
In the following example, all of the clients should complete within
2 seconds. (Assuming `PARALLEL` is defined to be large enough.)
[source,bash]
----
% export URL="tcp://127.0.0.1:55995"
# start the server
% ./raw $URL -s &
# start a bunch of clients
# Note that these all run concurrently!
% ./raw $URL 2 &
% ./raw $URL 2 &
% ./raw $URL 2 &
% ./raw $URL 2 &
% ./raw $URL 2 &
----