libevnet
is essentially the net
module of Node.JS (v0.2.6), implemented in C
Status: Release Candidate. Although there are a few missing features, tigerbot
has implemented a simple webserver atop libevn
and rumor is that it works well.
make
sudo make install
see source/echo-client.c
and source/echo-server.c
evn_stream* evn_create_connection(int port, char* address)
- create a Unix or TCP stream- If
port
is0
, a Unix Socket is assumed. Otherwise a TCP Socket is assumed.
- If
struct evn_stream* evn_stream_create(int fd)
struct evn_stream* evn_create_connection(EV_P_ int port, char* address)
void evn_stream_priv_on_read(EV_P_ ev_io *w, int revents)
bool evn_stream_write(EV_P_ struct evn_stream* stream, void* data, int size)
bool evn_stream_end(EV_P_ struct evn_stream* stream)
- closes (and frees) the streamvoid evn_stream_pause(EV_P_ struct evn_stream* stream)
// TODOvoid evn_stream_resume(EV_P_ struct evn_stream* stream)
// TODO
Event Callbacks
typedef void (evn_stream_on_connect)(EV_P_ struct evn_stream* stream)
typedef void (evn_stream_on_secure)(EV_P_ struct evn_stream* stream)
// TODOtypedef void (evn_stream_on_data)(EV_P_ struct evn_stream* stream, void* blob, int size)
typedef void (evn_stream_on_end)(EV_P_ struct evn_stream* stream)
typedef void (evn_stream_on_timeout)(EV_P_ struct evn_stream* stream)
typedef void (evn_stream_on_drain)(EV_P_ struct evn_stream* stream)
typedef void (evn_stream_on_error)(EV_P_ struct evn_stream* stream, struct evn_exception* error)
typedef void (evn_stream_on_close)(EV_P_ struct evn_stream* stream, bool had_error)
struct evn_server* evn_server_create(EV_P_ evn_server_on_connection* on_connection)
int evn_server_listen(struct evn_server* server, int port, char* address)
- create a Unix or TCP listener- If
port
is0
, a Unix Socket is assumed. Otherwise a TCP Socket is assumed.
- If
int evn_server_close(EV_P_ struct evn_server* server)
-- closes (and frees) the server
Event Callbacks
typedef void (evn_server_on_listen)(EV_P_ struct evn_server* server)
typedef void (evn_server_on_connection)(EV_P_ struct evn_server* server, struct evn_stream* stream)
typedef void (evn_server_on_close)(EV_P_ struct evn_server* server)