add a thp-based huge page alloc fallback
[pcsx_rearmed.git] / deps / libretro-common / samples / net / udp-test.c
1 /* public domain */
2 /* gcc -o udptest udp-test.c */
3
4 /*
5    will send "RETROPAD RIGHT" indefinely to player 1
6    to send to player 2 change port to 55401 and so on
7 */
8
9 #include <stdio.h>
10 #include <string.h>
11 #include <stdlib.h>
12 #include <arpa/inet.h>
13 #include <sys/socket.h>
14
15 #define SERVER "127.0.0.1"
16 #define PORT 55400
17
18 void die(char *s)
19 {
20     perror(s);
21     exit(1);
22 }
23
24 int main(void)
25 {
26    struct sockaddr_in si_other;
27    int s, i, slen=sizeof(si_other);
28
29    if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
30       die("socket");
31
32    memset((char *) &si_other, 0, sizeof(si_other));
33    si_other.sin_family = AF_INET;
34    si_other.sin_port = htons(PORT);
35
36    if (inet_aton(SERVER , &si_other.sin_addr) == 0)
37    {
38       fprintf(stderr, "inet_aton() failed\n");
39       exit(1);
40    }
41
42    for (;;)
43    {
44       char message[10]="128";
45       /* send the message */
46       if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1)
47          die("sendto()");
48
49       /* sleep for 1 frame (60hz) */
50       usleep(16*1000);
51    }
52
53    close(s);
54    return 0;
55 }