Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Application: basic-webserver, Web.h
- * Author: Project, UNX511, Team A
- * Description: Web class (header) - responsible for creating sockets and listening for connections.
- * A webserver that has been coded from scratch.
- * It uses Linux's socket library to deal with connections.
- *
- * This application is licensed under Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)
- * See this for more information: http://creativecommons.org/licenses/by-nc-sa/3.0/
- */
- #ifndef _INCL_WEB
- #define _INCL_WEB
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <sys/wait.h>
- #include <fcntl.h>
- // C++ way of including things.
- #include <string>
- #include <cstring>
- #include <map>
- #include <iostream>
- #include <cerrno>
- #include <cstdio>
- using namespace std;
- #define BUFSIZE 8096
- #define ERROR 11
- #define LOG 22
- #define HTTP_GENERIC_HEADER "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"
- class Web {
- private:
- int _socket;
- int _nSocket;
- int _port;
- socklen_t _clilen;
- struct sockaddr_in
- _serv_addr, _cli_addr;
- public:
- Web();
- Web(int port);
- int run();
- bool isHttpResponseOf(string haystack, string needle);
- void process(int socket);
- void log(int type, char* s1, char* s2, int num);
- ~Web();
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement