Newer
Older
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
/*
*
* Created on: Mar 1, 2021
* Author: astrisw
*
*/
#ifndef BASEPROTOCOL_H_
#define BASEPROTOCOL_H_
#include <iostream>
#include <netinet/in.h>
#include <Base_Packet.h>
/*
* class BaseSocket
* Implementation of a socket that allows to communicate with the sender.
* This parent class must be inherited in order to implement your own protocol,
* methods connect() and readPacket must be overridden
*
* @member field host: address of the host machine
* @member field port: listen port
* @member field protocol: communication protocol.
*/
class BaseProtocol{
protected:
std::string host;
int port;
public:
std::string getHost(){return host;}
int getPort(){return port;}
void setHost(std::string host){ this->host = host;}
void setPort(int port){this->port = port;}
virtual int connectToClient()=0;
virtual int connectToServer()=0;
virtual int rcvPacketFromCli(BasePacket &)=0;
virtual int sendPacketToSrv(BasePacket &)=0;
virtual ~BaseProtocol() = default;
};
#endif /* BASEPROTOCOL_H_ */