diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-09-18 23:58:47 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-09-18 23:58:47 -0400 |
commit | 7db333857219362ba14dec132825debc0d940a6c (patch) | |
tree | 084c7f16f0087b03de593396f5994ca8042b0acd /listener.c | |
parent | 779ce6a6885346257b4d18f1efe205984cfff079 (diff) |
cleanup some bugs. you can now listen to the music! good stopping point
Diffstat (limited to 'listener.c')
-rw-r--r-- | listener.c | 23 |
1 files changed, 15 insertions, 8 deletions
@@ -83,7 +83,7 @@ int main(int argc, char *argv[]) int count = 0; while(1) { - printf("\nlistener: waiting to recvfrom... %d times\n", count++); + // printf("\nlistener: waiting to recvfrom... %d times\n", count++); addr_len = sizeof their_addr; if ((numbytes = recvfrom(sockfd, buf, MAXBUFLEN , 0, @@ -91,14 +91,21 @@ int main(int argc, char *argv[]) perror("recvfrom"); exit(1); } + // buf[numbytes] = '\0'; - printf("listener: got packet from %s\n", - inet_ntop(their_addr.ss_family, - get_in_addr((struct sockaddr *)&their_addr), - s, sizeof s)); - printf("listener: packet is %d bytes long\n", numbytes); - buf[numbytes] = '\0'; - printf("listener: packet contains \"%s\"\n", buf); + //printf("listener: got packet from %s\n", + // inet_ntop(their_addr.ss_family, + // get_in_addr((struct sockaddr *)&their_addr), + // s, sizeof s)); + //printf("listener: packet is %d bytes long\n", numbytes); + //buf[numbytes] = '\0'; + //printf("listener: packet contains \"%s\"\n", buf); + + // print the size + + write(STDOUT_FILENO, buf, numbytes); + + memset(buf, 0, MAXBUFLEN); } close(sockfd); |