aboutsummaryrefslogtreecommitdiff
path: root/listener.c
diff options
context:
space:
mode:
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);