From e463cfd3cbd419dc38583fe25b93be36b330a606 Mon Sep 17 00:00:00 2001 From: Gaspar Fernandez Date: Fri, 12 Aug 2016 01:29:28 +0200 Subject: Version 0.4d --- src/MySock.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/MySock.h (limited to 'src/MySock.h') diff --git a/src/MySock.h b/src/MySock.h new file mode 100644 index 0000000..132978c --- /dev/null +++ b/src/MySock.h @@ -0,0 +1,62 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +#define MAX_LINE 100 +#define LINE_ARRAY_SIZE (MAX_LINE+1) + +#define NO_ERROR 0 +#define CANT_CREATE_SOCKET 20 +#define CANT_RESOLVE_HOST 30 +#define CANT_CONNECT 35 +#define CANT_SEND_DATA 40 +#define CANT_READ_DATA 45 +#define NO_VALID_PROTOCOL 50 +#define NO_VALID_HEADERS 52 + +#define CRLF "\r\n" +struct HTTP_Request +{ + string statusstr; + int status; + string date; + string server; + string last_modified; + string content_type; + string content_length; + string data; +}; + +struct TKey_Value +{ + string key, value; +}; + +class MySock { +public: + int error; + bool connected; + + string GetTextData(); + int SendData(string data); + HTTP_Request *GetHTTPData(); + void closeConnection(); + MySock(); + MySock(string server, int port); + MySock(string uri); + virtual ~MySock(); +private: + int sockd, puerto; + struct hostent *server; + + void MakeConnection (string server, int port); +}; + +TKey_Value extract_key_value(string str); -- cgit v1.2.1