blob: 86ab04e22ca5ded3cb78b62b90a6b5f47c1949a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# lua-nng
This is a simple binding of [Nanomessage Next Generation](https://github.com/nanomsg/nng) to lua.
## Installation
First you'll need a copy of [nng](https://github.com/nanomsg/nng)
git clone https://github.com/nanomsg/nng
cd nng
mkdir build
cd build
cmake .. -DBUILD_SHARED_LIBS=True
make && sudo make install
The easiest way to download lua-nng is with [luarocks](https://github.com/luarocks/luarocks).
You can also clone this repository and build locally
git clone https://cogarr.net/source/cgit.cgi/lua-nng
cd lua-nng
sudo luarocks build
```
luarocks install --server=http://rocks.cogarr.net lua-nng
```
## Example
local nng = require("nng")
local s1 = nng.pair1_open()
local s2 = nng.pair1_open()
s1:listen("ipc:///tmp/pair.ipc")
s2:dial("ipc:///tmp/pair.ipc")
s2:send("hello")
print(s1:recv()) --prints "hello"
For more examples, see spec/start\_spec.lua
|