micclient: fix typo in comment
[rofl0r-rocksock.git] / examples / ringserver.c
blobe52a6383587289165a84a325324dbad458df13eb
1 /* example of a simple server that plays a wave file using aplay when
2 someone connects. */
4 #include "../rocksockserver.h"
5 #include <sys/wait.h>
6 #include <unistd.h>
8 int on_clientconnect (void* userdata, struct sockaddr_storage* clientaddr, int fd) {
9 rocksockserver *s = userdata;
10 rocksockserver_disconnect_client(s, fd);
11 pid_t pid = fork();
12 if(!pid) execl("/bin/sh", "/bin/sh", "-c", "aplay /root/ring.wav", (char*) 0);
13 else waitpid(pid, 0, 0);
14 return 0;
17 int main() {
18 int port = 9999;
19 char* listenip = "0.0.0.0";
20 rocksockserver s;
21 if(rocksockserver_init(&s, listenip, port, &s)) return -1;
22 if(rocksockserver_loop(&s, NULL, 0, &on_clientconnect, 0, 0, 0)) return -2;
23 return 0;