aboutsummaryrefslogtreecommitdiffstats
path: root/small-codes
diff options
context:
space:
mode:
Diffstat (limited to 'small-codes')
-rw-r--r--small-codes/syslog-listen.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/small-codes/syslog-listen.c b/small-codes/syslog-listen.c
index c878076..e248608 100644
--- a/small-codes/syslog-listen.c
+++ b/small-codes/syslog-listen.c
@@ -34,13 +34,13 @@ int main(int argc, const char** argv)
int ret = bind(sock, (struct sockaddr*)&sock_file, sizeof(sock_file));
PERROR(ret, "bind");
- char buf[8192];
- int receive;
+ char buf[8192 + 1];
+ int received;
while (1) {
- receive = recv(sock, buf, sizeof(buf), 0);
- PERROR(receive, "recv");
- buf[receive] = '\0';
- printf("received: %s\n", buf);
+ received = recv(sock, buf, sizeof(buf)-1, 0);
+ PERROR(received, "recv");
+ buf[received] = '\n';
+ write(1, buf, received+1);
}
return 0;