-
Notifications
You must be signed in to change notification settings - Fork 0
/
NETWORKMANAGER.H
59 lines (40 loc) · 995 Bytes
/
NETWORKMANAGER.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
54
55
56
57
58
#ifndef _NETWORKMANAGER_H
#define _NETWORKMANAGER_H
#include <map>
#include <string>
#include <memory>
#include <netinet/in.h>
//#include <pthread.h>
const int TCP = 0;
const int PORT = 7676;
const int MAX_CONNECTIONS = 5;
namespace Affine{
class Socket
{
private:
const std::string mHostName;
int mSocketFd;
struct sockaddr_in mServerAddr;
public:
Socket( const std::string hostname, const int port );
inline const std::string* getHostName() { return &mHostName; };
bool accept( Socket &socket ) const;
bool send( const void* data ) const;
int recieve( void* data ) const;
};
class NetworkManager
{
private:
std::auto_ptr< Socket > mHost;
NetworkManager *mInstance;
std::map<std::string, Socket> mHostsMap;
void init( );
protected:
NetworkManager( );
public:
virtual ~NetworkManager() {};
void addSocket( const Socket socket );
void sendFile( const void* data, const std::string hostname );
};
}
#endif