-
Notifications
You must be signed in to change notification settings - Fork 1
/
slothSock.hpp
58 lines (49 loc) · 1.34 KB
/
slothSock.hpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************
A Docile Sloth 2016 ([email protected])
*******************************************/
#ifndef SLOTHSOCK_HPP
#define SLOTHSOCK_HPP
#include <vector>
#include <string>
#if _WIN32
#include <winsock2.h>
#include <windows.h>
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
class slothSock
{
private:
SOCKET sock;
public:
slothSock() {};
bool connectToHost(int port, char* adrs);
void closeConnection();
bool sendAll(char *buffer, int length, int flag);
bool sendAll(const char *buffer, int length, int flag);
bool recvAll(char *buffer, int length, int flag);
bool recvAll(std::vector<char> &vbuffer, int length, int flag);
bool recvAll(char *buffer, int length, int flag, std::string endid);
};
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
class slothSock
{
private:
int sock;
public:
slothSock() {};
bool connectToHost(int port, char* adrs);
void closeConnection();
bool sendAll(char *buffer, int length, int flag);
bool sendAll(const char *buffer, int length, int flag);
bool recvAll(char *buffer, int length, int flag);
bool recvAll(std::vector<char> &vbuffer, int length, int flag);
bool recvAll(char *buffer, int length, int flag, std::string endid);
};
#endif
#endif