diff --git a/src/hdbd.c b/src/hdbd.c index 601ec00..092f0ff 100644 --- a/src/hdbd.c +++ b/src/hdbd.c @@ -61,30 +61,39 @@ int main() { return 1; } - syslog(LOG_INFO, "Listening for connections..."); - /* Actual program */ int client_sock; int data_length = 0; char receive_buf[1000]; char send_buf[1000]; + char log_line[10000]; memset(receive_buf, 0, sizeof receive_buf); memset(send_buf, 0, sizeof send_buf); + memset(log_line, 0, sizeof log_line); + + + syslog(LOG_INFO, "Listening for connections..."); while(1) { client_sock = accept(server_sock, NULL, NULL); if (client_sock == -1) { return 1; } + syslog(LOG_INFO, "Accepted a connection"); data_length = recv(client_sock, receive_buf, sizeof receive_buf, 0); if (data_length <= 0) { + syslog(LOG_WARNING, "Received no data from client"); strcpy(send_buf, "Failed to receive any data."); send(client_sock, send_buf, strlen(send_buf), 0); close(client_sock); continue; } + + sprintf(log_line, "Received from Client: %s", receive_buf); + syslog(LOG_DEBUG, log_line); - if (strstr(send_buf, "shutdown") != NULL) { + if (strstr(receive_buf, "shutdown") != NULL) { + syslog(LOG_NOTICE, "Shutting down"); strcpy(send_buf, "Shutting down."); send(client_sock, send_buf, strlen(send_buf), 0); close(client_sock);