2 /* gcc -o udptest udp-test.c */
5 will send "RETROPAD RIGHT" indefinely to player 1
6 to send to player 2 change port to 55401 and so on
12 #include <arpa/inet.h>
13 #include <sys/socket.h>
15 #define SERVER "127.0.0.1"
26 struct sockaddr_in si_other;
27 int s, i, slen=sizeof(si_other);
29 if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
32 memset((char *) &si_other, 0, sizeof(si_other));
33 si_other.sin_family = AF_INET;
34 si_other.sin_port = htons(PORT);
36 if (inet_aton(SERVER , &si_other.sin_addr) == 0)
38 fprintf(stderr, "inet_aton() failed\n");
44 char message[10]="128";
45 /* send the message */
46 if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1)
49 /* sleep for 1 frame (60hz) */