libuv i a multi-platform library for asynchronous, event-driven style of programming. It offers core utilities like timers, non-blocking networking support, asynchronous file system access, child processes and more.
libuv libraries available at biicode are:
- libuv v0.10 at lasote/libuv (v0.10).
- libuv v0.11 at lasote/libuv (v0.11).
- libuv v1.x at lasote/libuv (v1.x).
Blocks are generated for this github repo.
In this example we’ll show a Http client/server application.
This example is already in biicode at examples/libuv(v0.11). So just open the block:
$ bii init libuvproject
$ cd libuvproject
$ bii open examples/libuv(v.11)
Let’s check the dependecies of this example:
$ bii deps
INFO: Processing changes...
examples/libuv depends on:
lasote/libuv(v0.11): 2
include/uv.h
system:
stdio.h
stdlib.h
string.h
Now take a look at biicode.conf file:
[requirements]
lasote/libuv (v0.11): 2
[parent]
examples/libuv(v0.11): 1
[includes]
uv.h: lasote/libuv/include
Note that the original [includes]
are mapped, so you just have to #include "uv.h"
to add libuv to the project.
Now execute bii build to build the project.
$ bii build
Go to bin directory and execute:
$ cd bin
$ examples_libuv_network_server.exe
And in other terminal/console:
$ cd bin
$ examples_libuv_network_client.exe
And you’ll see the next output:
Server | Client |
---|---|
Connection ok! Received: Ping... Sending: Ping... Pong! Closed ok! |
Writing: Ping... Write ok! Received: Ping... Pong! |
Hey! That’s your ping-pong client/server application!
You can change among libuv’s versions with just a single mod in biicode.conf file:
To depend on libuv v0.10:
[requirements] lasote/libuv (v0.10): 3
To depend on libuv v0.11:
[requirements] lasote/libuv (v0.11): 2
To depend on libuv v1.x:
[requirements] lasote/libuv (v1.x): 7
Try the example above switching versions!
Got any doubts? Do not hesitate to contact us, visit our forum and feel free to ask any questions.