#include #include #include #include "socket.h" #include "display.h" #include "typedef.h" static int fd; void on_recv(char *buf, int numbytes) { // read and play audio write(fd, buf, numbytes); } int main(int argc, char **argv) { int pipefd[2]; if(pipe2(pipefd, O_NONBLOCK) == -1) { fputs("pipe: failed", stderr); return 1; } pid_t p = fork(); if(p < 0) { fputs("fork: failed", stderr); return 1; } else if(p > 0) { close(pipefd[0]); fd = pipefd[1]; return listener("4950", &on_recv); } else { close(pipefd[1]); display(&argc, argv, pipefd[0]); } }