The Trickles server API is replacement for Berkeley sockets. It is an event-based API that is optimized for implementing stateless services, and does not require any persistent per-connection state. This event-based API is programmed in the standard interrupt-driven method. Trickles events are generated in response to packets received from the client. Each event is a minisocket. A minisocket is like a socket in that it identifies a particular client, and supports socket-like endpoint operations like sending data and closing the connection. Unlike a socket, a minisocket is deallocated immediately after processing the event.

Minisockets provide the application with a simple, narrow interface. Trickles supports the following operations on minisockets. The file descriptor refers to the listening socket bound to the server port.

msk_send(int fd, minisock *, char *, size_t);
msk_sendv(int fd, minisock *, tiovec *, int);
msk_sendfilev(int fd, minisock *, fiovec *, int);
msk_setucont(int fd, minisock *, int pkt,
                  char* buf, size_t);
msk_sendbulk(int fd, mskdesc *, int len);
msk_drop(int fd, minisock *);
msk_detach(int fd, minisock *);
msk_extract_events(int fd, extract_mskdesc_in *,
           int inlen, msk_collection *, int *outlen);
msk_install_events(int fd, msk_collection *, int);
msk_request(int fd, char *req, int reqlen,
           int reservelen);
Trickles server API

The figure below demonstrates how a Trickles web server uses the Trickles server API. Upon receiving the HTTP request from the client, the server kernel generates msk0 within a queue that is mapped in both the kernel and application. The server is unblocked, and performs operations on the new minisocket: it sets the inode continuation and sends data. Upon sending the data and updated continuation, msk0 is destroyed.

Trickles webserver


Trickles is backwards compatible with standard TCP on the client side, and provides the standard Berkeley sockets API to client applications. Thus, client applications can run unmodified.