blob: 0a5df2de2eee471fc0a3d9738dba89b7c3cbc481 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#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]);
}
}
|