summaryrefslogtreecommitdiff
path: root/src/MySock.h
diff options
context:
space:
mode:
authorGaspar Fernandez <gaspar.fernandez@totaki.com>2016-08-12 01:29:28 +0200
committerGaspar Fernandez <gaspar.fernandez@totaki.com>2016-08-12 01:29:28 +0200
commite463cfd3cbd419dc38583fe25b93be36b330a606 (patch)
treeadd192be35a2e37ace95ee6f33a0a65d612dad9b /src/MySock.h
parentf5932870164b72d2a67352495f3062f31f1fc5fd (diff)
downloaddwgo-e463cfd3cbd419dc38583fe25b93be36b330a606.tar.gz
dwgo-e463cfd3cbd419dc38583fe25b93be36b330a606.tar.bz2
dwgo-e463cfd3cbd419dc38583fe25b93be36b330a606.zip
Version 0.4d
Diffstat (limited to 'src/MySock.h')
-rw-r--r--src/MySock.h62
1 files changed, 62 insertions, 0 deletions
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 <stdio.h>
+#include <string.h>
+#include <strings.h>
+#include <iostream>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+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);