-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdatacastServer.h
62 lines (46 loc) · 1.71 KB
/
datacastServer.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
59
60
61
62
#ifndef _DATACASTSERVER_H_
#define _DATACASTSERVER_H_
#include "configure.h"
#include "debug.h"
#include "packet.h"
#include "packetDatacast.h"
#ifdef WIN32
#include <winsock2.h>
#else
#include <fcntl.h>
#include <sys/socket.h> /* for socket(), bind(), and connect() */
#include <sys/select.h> /* for fd_set() */
#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */
#include <unistd.h> /* for close() */
#endif
#define DCSET 0x00
#define DCRAW 0x01
#define DCFORMATA 0x02
#define DCOK 0x00 /* command successful */
#define DCTRUNC 0xfd /* command completed but data was truncated */
#define DCFULL 0xfe /* command failed as buffer is full */
#define DCERR 0xff /* command failed */
namespace ttx
{
class DatacastServer
{
public:
DatacastServer(ttx::Configure *configure, vbit::Debug *debug);
~DatacastServer();
void run();
bool GetIsActive(){return _isActive;}; /* is the packet server running? */
vbit::PacketDatacast** GetDatachannels() { vbit::PacketDatacast **channels=_datachannel; return channels; };
private:
vbit::Debug* _debug;
vbit::PacketDatacast* _datachannel[16]; /* array of datacast sources */
static const uint16_t MAXPENDING=5;
static const uint16_t MAXCLIENTS=5;
int _portNumber;
int _serverSock;
int _clientSocks[MAXCLIENTS];
int _clientChannel[MAXCLIENTS];
bool _isActive;
void SocketError(std::string errorMessage); // handle fatal socket errors
};
}
#endif