-
Notifications
You must be signed in to change notification settings - Fork 0
/
Network.hpp
42 lines (36 loc) · 811 Bytes
/
Network.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
#ifndef NETWORK_HPP
#define NETWORK_HPP
#include <iostream>
#include <fcntl.h>
#include "Singleton.hpp"
#include "Tracer.hpp"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#define g_pNetwork CNetwork::Get()
#define BUF_SIZE 4096
class CNetwork : public TSingleton<CNetwork>
{
public:
CNetwork (void);
int InitNetwork (void);
int ConnectToClient (void);
int Send (void);
int Receive (void);
void CreatePackage (uint16_t nData);
private:
int m_nSocketFromServer;
int m_nSocketFromClient;
int m_nBytes;
socklen_t SizeOfClientSocket;
char m_chBuffer[BUF_SIZE];
struct sockaddr_in AdressFromServer;
struct sockaddr_in AdressfromClient;
};
#endif