cs-3516-assignment-1/server/socket_server.h

23 lines
597 B
C

#ifndef SOCKET_SERVER
#define SOCKET_SERVER
#include "../common/socket_helper.h"
#define LISTEN_ADDR "::"
#define BACKLOG_SIZE 8
#define HTTP_VERSION "HTTP/1.1"
#define DATE_FORMAT "%a, %d %b %Y %H:%M:%S %Z"
#define FILE_BUFFER_SIZE 1024
enum server_status {STATUS_LISTENING, STATUS_CLOSED, STATUS_ERROR};
enum request_parse_result {PARSE_RESULT_OK, PARSE_RESULT_MALFORMED, PARSE_RESULT_BAD_METHOD, PARSE_RESULT_BAD_VERSION};
struct server_info {
int sock_fd;
enum server_status status;
};
struct server_info setup(int port);
enum socket_result serve_one_request(int sock_fd);
#endif