Commit 17639659 authored by xiezhi's avatar xiezhi

fix

parent 731707c8
......@@ -4,6 +4,7 @@
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
......@@ -15,6 +16,7 @@ volatile sig_atomic_t keep_running = 1;
// Signal handler function
void handle_signal(int sig) {
(void)sig; // Suppress unused parameter warning
keep_running = 0;
}
......@@ -73,9 +75,9 @@ int main() {
exit(EXIT_FAILURE);
}
// Set socket options to reuse address and port
// Set socket options to reuse address
int opt = 1;
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt))) {
if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))) {
perror("setsockopt failed");
exit(EXIT_FAILURE);
}
......@@ -124,8 +126,11 @@ int main() {
get_time_string(time_buffer, sizeof(time_buffer));
printf("[%s] Request from %s\n", time_buffer, client_ip);
read(new_socket, buffer, BUFFER_SIZE);
write(new_socket, http_response, strlen(http_response));
ssize_t bytes_read = read(new_socket, buffer, BUFFER_SIZE);
(void)bytes_read; // Suppress unused variable warning
ssize_t bytes_written = write(new_socket, http_response, strlen(http_response));
(void)bytes_written; // Suppress unused variable warning
close(new_socket);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment