Skip to content

Commit a9bf389

Browse files
committed
Updates
1 parent 8c59c79 commit a9bf389

1 file changed

Lines changed: 30 additions & 34 deletions

File tree

samples/net/udp-test.c

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,33 @@ void die(char *s)
2323

2424
int main(void)
2525
{
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-
{
31-
die("socket");
32-
}
33-
34-
memset((char *) &si_other, 0, sizeof(si_other));
35-
si_other.sin_family = AF_INET;
36-
si_other.sin_port = htons(PORT);
37-
38-
if (inet_aton(SERVER , &si_other.sin_addr) == 0)
39-
{
40-
fprintf(stderr, "inet_aton() failed\n");
41-
exit(1);
42-
}
43-
while(1)
44-
{
45-
46-
char message[10]="128";
47-
//send the message
48-
if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1)
49-
{
50-
die("sendto()");
51-
}
52-
/* sleep for 1 frame (60hz) */
53-
usleep(16*1000);
54-
55-
}
56-
57-
close(s);
58-
return 0;
59-
}
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+
}

0 commit comments

Comments
 (0)