2 #include <netinet/in.h>
7 #include <sys/socket.h>
11 //#define SRV_IP "192.168.129.255"
12 #define SRV_IP "255.255.255.255"
17 unsigned char buf[LEN];
19 void print_until(unsigned char until);
23 void print_until(unsigned char until)
26 for ( i=0;i<=until;i++){
48 /* diep(), #includes and #defines like in the server */
57 struct sockaddr_in si_other;
58 struct ifreq interface;
59 int s, i, slen=sizeof(si_other);
60 int val=1,size=sizeof(val);
63 printf("hello: Socket\n");
64 if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1)
67 printf("hello: sockopt\n");
68 memset(&interface, 0, sizeof(interface));
69 strncpy(interface.ifr_ifrn.ifrn_name, "bnep0",
70 sizeof(interface.ifr_ifrn.ifrn_name));
72 if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, &interface,
73 sizeof(interface)) < 0){
77 retn = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &val, size);
79 perror("SO_BROADCAST");
86 memset((char *) &si_other, 0, sizeof(si_other));
87 si_other.sin_family = AF_INET;
88 si_other.sin_port = htons(PORT);
90 if (inet_aton(SRV_IP, &si_other.sin_addr)==0) {
91 fprintf(stderr, "inet_aton() failed\n");
95 printf("hello: Send packet\n");
96 printf("Sending packet %d\n", i);
97 if (sendto(s, buf, LEN, 0, (const struct sockaddr *)&si_other, slen)==-1)