aboutsummaryrefslogtreecommitdiff
path: root/listener.c
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-09-18 23:58:47 -0400
committersotech117 <michael_foiani@brown.edu>2023-09-18 23:58:47 -0400
commit7db333857219362ba14dec132825debc0d940a6c (patch)
tree084c7f16f0087b03de593396f5994ca8042b0acd /listener.c
parent779ce6a6885346257b4d18f1efe205984cfff079 (diff)
cleanup some bugs. you can now listen to the music! good stopping point
Diffstat (limited to 'listener.c')
-rw-r--r--listener.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/listener.c b/listener.c
index 2d46307..d5b4799 100644
--- a/listener.c
+++ b/listener.c
@@ -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);