mirror of
https://github.com/opus-tango/http-server-in-c.git
synced 2026-03-20 03:55:25 +00:00
accept connections
This commit is contained in:
14
webserver.c
14
webserver.c
@@ -33,4 +33,18 @@ int main(int argc, char **argv) {
|
||||
perror("listen failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
struct sockaddr_in client_addr;
|
||||
socklen_t client_len = sizeof(client_addr);
|
||||
int *client = malloc(sizeof(int));
|
||||
|
||||
*client = accept(server, (struct sockaddr *)&client_addr, &client_len);
|
||||
if (client < 0) {
|
||||
perror("Failed to accept client");
|
||||
continue;
|
||||
} else {
|
||||
printf("Client connected\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user