Mercurial > hg > beaglert
comparison resources/network/udp-server.c @ 132:e24c531220ee scope-refactoring
Added some sort of synchronization, not working great though
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Thu, 27 Aug 2015 01:42:04 +0100 |
parents | fb56681ab1d6 |
children |
comparison
equal
deleted
inserted
replaced
131:ff28e56e5b7e | 132:e24c531220ee |
---|---|
46 while (1) { | 46 while (1) { |
47 n = recvfrom(sock,buf,2048,0,(struct sockaddr *)&from,&fromlen); | 47 n = recvfrom(sock,buf,2048,0,(struct sockaddr *)&from,&fromlen); |
48 if (n < 0) error("recvfrom"); | 48 if (n < 0) error("recvfrom"); |
49 printf("Received a datagram of size %d: \n", n); | 49 printf("Received a datagram of size %d: \n", n); |
50 printf("Header: channel: %d, timestamp: %d\n", (int)buf[0], (int)buf[1]); | 50 printf("Header: channel: %d, timestamp: %d\n", (int)buf[0], (int)buf[1]); |
51 for(i=2; i<n/sizeof(float); i+=8) | 51 // for(i=2; i<n/sizeof(float); i+=8) |
52 printf("%+f, %+f, %+f, %+f, %+f, %+f, %+f, %+f\n",i,buf[0+i],buf[1+i],buf[2+i],buf[3+i],buf[4+i],buf[5+i],buf[6+i],buf[7+i]); | 52 // printf("%+f, %+f, %+f, %+f, %+f, %+f, %+f, %+f\n",buf[0+i],buf[1+i],buf[2+i],buf[3+i],buf[4+i],buf[5+i],buf[6+i],buf[7+i]); |
53 n = sendto(sock,"Got your message\n",17, | 53 // n = sendto(sock,"Got your message\n",17, |
54 0,(struct sockaddr *)&from,fromlen); | 54 // 0,(struct sockaddr *)&from,fromlen); |
55 if (n < 0) error("sendto"); | 55 // if (n < 0) error("sendto"); |
56 } | 56 } |
57 return 0; | 57 return 0; |
58 } | 58 } |
59 | 59 |