Application: Applications have to register their sockets in order
to benefit of FLOC rate control. They associate a token to
one or several sockets that will share the rate profile of it.
This can be achieved by hijacking libc's connect() function or
by calling FLOC functions directly from C code as shown in the code snippet below.
int main()
{
/* Usual connect() stuff */
int sockfd = socket(...);
connect(sockfd, ...);
/* FLOC code */
id_t proc;
id_t flow;
/* Create connection to FLOC daemon */
sfc_connect();
/* Register token "ABCDEFABCDEF" */
proc = sfc_proc_new("ABCDEFABCDEF");
/* Add flow */
flow = sfc_flow_add(proc, sockfd, NULL, NULL);
/* Wait for mark/classid */
sfc_wait(proc, flow);
fprintf(stderr, "[FLOC] go\n");
write(sockfd, "Hello", 5);
/* Flow unregistration */
sfc_flow_del(proc, flow);
close(sockfd);
}