-
Notifications
You must be signed in to change notification settings - Fork 1
/
CSocket.h
56 lines (42 loc) · 1.12 KB
/
CSocket.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
/*
* Copyright (c) 2012 Alexandros Nikolopoulos <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*/
#ifndef CSOCKET_H_
#define CSOCKET_H_
#include "fpd.h"
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <errno.h>
class CSocket : public CInterface
{
public:
CSocket(map<string, string> settings);
virtual ~CSocket();
int Connect(void);
int Disconnect(void);
int Send(uint8_t *message, int length);
int Receive(uint8_t *message, int length, time_t timeout);
// FIXME Add a function to this
string GetMyAddress(void) { return "";};
private:
int ReConnect(void);
string m_host;
uint16_t m_port;
bool m_IsConnected;
int m_Socket;
pthread_mutex_t m_SocketMutex;
};
#endif /* CSOCKET_H_ */