-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtiny_botzd.c
More file actions
40 lines (30 loc) · 920 Bytes
/
tiny_botzd.c
File metadata and controls
40 lines (30 loc) · 920 Bytes
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
#include <string.h>
#include <unistd.h>
#include "botz.h"
#include "json.h"
#include "trace.h"
int main(int argc, char *argv[])
{
struct botz_listen bl;
struct evx_listen *el;
int up = 1;
unsigned long nr_clients = 1000000;
struct json status_json[] = {
J_OBJECT,
J_PAIR("name", string, V, "tiny_botzd"),
J_PAIR("up", bool, P, &up),
J_PAIR("nr_clients", ulong, P, &nr_clients),
J_END,
};
if (botz_listen_init(&bl, 64) < 0)
FATAL("cannot initialize listener: %s\n", strerror(errno));
if (botz_set_json(&bl, "/status", status_json, NULL) < 0)
FATAL("cannot set resource `/status': %s\n", strerror(errno));
el = &bl.bl_listen;
if (evx_listen_bind_name(el, "localhost", "9901", 0, 128) < 0)
FATAL("cannot bind to interface `localhost', service `9901': %s\n",
strerror(errno));
evx_listen_start(EV_DEFAULT_ el);
ev_run(EV_DEFAULT_ 0);
return 0;
}