blob: 0c96b9918836f3a654839e40cb374f42bb62c561 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include "net.h"
#define CFWS_DEFAULT_PORT 8080
int main(int argc, char *argv[])
{
	int port = CFWS_DEFAULT_PORT;
	int serverfd, clientfd;
	serverfd = initialize_server(port);
	if (serverfd == -1)
		return 1;
	printf("Serving a directory at localhost:%d\n", port);
	while (1) {
		clientfd = accept(serverfd, NULL, NULL);
		handle_connection(clientfd);
		close(clientfd);
	}
	close(serverfd);
	return 0;
}
 |