diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-02-08 10:36:38 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-02-08 10:36:38 -0800 |
| commit | e9efefca683b244b40f831c554d7c72a745b8372 (patch) | |
| tree | 47a88e80fefe39b8b7b895fd603b1c6f18afb82d /demo/reqrep/README.adoc | |
| parent | 91b3c83ce71dba060f418192488debf16f003e74 (diff) | |
| download | nng-e9efefca683b244b40f831c554d7c72a745b8372.tar.gz nng-e9efefca683b244b40f831c554d7c72a745b8372.tar.bz2 nng-e9efefca683b244b40f831c554d7c72a745b8372.zip | |
Add reqrep demo, but demonstrate zero copy, and sending binary data.
Diffstat (limited to 'demo/reqrep/README.adoc')
| -rw-r--r-- | demo/reqrep/README.adoc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/demo/reqrep/README.adoc b/demo/reqrep/README.adoc new file mode 100644 index 00000000..b66d694c --- /dev/null +++ b/demo/reqrep/README.adoc @@ -0,0 +1,48 @@ += reqrep + +This is a very simple RPC service using the REQ/REP method. +It is derived in part from Tim Dysinger's +http://nanomsg.org/gettingstarted/[Getting Started With Nanomsg] +examples, but we have updated for _nng_, and converted to use binary +frames across the wire instead of string data. + +The protocol is simple: + +* Client will send a 64-bit command (network byte order, i.e. big endian). +* Server sends a 64-bit response (also network byte order.) + +The only command is "DATE", which has value 0x1. The value returned is +a UNIX timestamp (seconds since Jan 1, 1970.) + +(We used 64-bit values for simplicity, and to avoid the Y2038 bug when +compiled on 64-bit systems.) + +== Compiling + +The following is an example typical of UNIX and similar systems like +Linux and macOS: + +[source, bash] +---- +% export CPPFLAGS="-I /usr/local/include" +% export LDFLAGS="-L /usr/local/lib -lnng" +% export CC="cc" +% ${CC} ${CPPFLAGS} reqrep.c -o reqrep ${LDFLAGS} +---- + +== Running + +You can run either the client or the server, and use whatever legal +_nng_ URL you like: + +[source, bash] +---- +% ./reqrep server tcp://127.0.0.1:8899 & +% ./reqrep client tcp://127.0.0.1:8899 +CLIENT: SENDING DATE REQUEST +SERVER: RECEIVED DATE REQUEST +SERVER: SENDING DATE: Thu Feb 8 10:26:18 2018 +CLIENT: RECEIVED DATE: Thu Feb 8 10:26:18 2018 +---- + + |
