forked from SharifAIChallenge/AIC16-Client-Cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Network.h
53 lines (47 loc) · 984 Bytes
/
Network.h
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
/*
* Network.h
*
* Created on: Feb 4, 2015
* Author: rmin
*/
#ifndef NETWORK_H_
#define NETWORK_H_
#define MAX_LEN_OF_TCP 66000
#include "Message.h"
#include <vector>
#include "SubPacket.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
class Controller;
class Network {
std::vector<SubPacket*> packets;
bool isTerminated;
int port;
std::string host;
std::string token;
bool isConnected;
int sockfd;
struct sockaddr_in serv_addr;
struct hostent *server;
bool doReceive();
void startReceiving();
Controller* controller;
public:
Network(Controller* controller);
void sendMessage(Message &msg);
void parse();
void terminate();
void setConnectionData(std::string host,int port,std::string token);
void connect();
virtual ~Network();
bool getIsConnected();
bool getIsTerminated();
void clearPacket();
};
#endif /* NETWORK_H_ */