X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=deps%2Flibretro-common%2Fsamples%2Fnet%2Fudp-test.c;fp=deps%2Flibretro-common%2Fsamples%2Fnet%2Fudp-test.c;h=3366cf55cca070e43093380b7431845ce6530395;hb=3719602cbe883fb394a71353e20a10a4a306e814;hp=0000000000000000000000000000000000000000;hpb=8659d7fd2cdb11f63724ead0997f47f4c694f8c2;p=pcsx_rearmed.git diff --git a/deps/libretro-common/samples/net/udp-test.c b/deps/libretro-common/samples/net/udp-test.c new file mode 100644 index 00000000..3366cf55 --- /dev/null +++ b/deps/libretro-common/samples/net/udp-test.c @@ -0,0 +1,55 @@ +/* public domain */ +/* gcc -o udptest udp-test.c */ + +/* + will send "RETROPAD RIGHT" indefinely to player 1 + to send to player 2 change port to 55401 and so on +*/ + +#include +#include +#include +#include +#include + +#define SERVER "127.0.0.1" +#define PORT 55400 + +void die(char *s) +{ + perror(s); + exit(1); +} + +int main(void) +{ + struct sockaddr_in si_other; + int s, i, slen=sizeof(si_other); + + if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) + die("socket"); + + memset((char *) &si_other, 0, sizeof(si_other)); + si_other.sin_family = AF_INET; + si_other.sin_port = htons(PORT); + + if (inet_aton(SERVER , &si_other.sin_addr) == 0) + { + fprintf(stderr, "inet_aton() failed\n"); + exit(1); + } + + for (;;) + { + char message[10]="128"; + /* send the message */ + if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1) + die("sendto()"); + + /* sleep for 1 frame (60hz) */ + usleep(16*1000); + } + + close(s); + return 0; +}