-
Notifications
You must be signed in to change notification settings - Fork 6
/
socket.h
71 lines (60 loc) · 1.63 KB
/
socket.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
63
64
65
66
67
68
69
70
/*
* socket.h: IPTV plugin for the Video Disk Recorder
*
* See the README file for copyright information and how to reach the author.
*
*/
#ifndef __IPTV_SOCKET_H
#define __IPTV_SOCKET_H
#include <arpa/inet.h>
#ifdef __FreeBSD__
#include <netinet/in.h>
#endif // __FreeBSD__
class cIptvSocket {
private:
int socketPortM;
protected:
enum {
eReportIntervalS = 300 // in seconds
};
int socketDescM;
struct sockaddr_in sockAddrM;
time_t lastErrorReportM;
int packetErrorsM;
int sequenceNumberM;
bool isActiveM;
protected:
bool OpenSocket(const int portP, const bool isUdpP);
void CloseSocket(void);
bool CheckAddress(const char *addrP, in_addr_t *inAddrP);
public:
cIptvSocket();
virtual ~cIptvSocket();
};
class cIptvUdpSocket : public cIptvSocket {
private:
in_addr_t streamAddrM;
in_addr_t sourceAddrM;
bool useIGMPv3M;
public:
cIptvUdpSocket();
virtual ~cIptvUdpSocket();
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
bool OpenSocket(const int Port);
bool OpenSocket(const int Port, const char *streamAddrP, const char *sourceAddrP, bool useIGMPv3P);
void CloseSocket(void);
bool JoinMulticast(void);
bool DropMulticast(void);
};
class cIptvTcpSocket : public cIptvSocket {
public:
cIptvTcpSocket();
virtual ~cIptvTcpSocket();
virtual int Read(unsigned char* bufferAddrP, unsigned int bufferLenP);
bool OpenSocket(const int portP, const char *streamAddrP);
void CloseSocket(void);
bool ConnectSocket(void);
bool ReadChar(char* bufferAddrP, unsigned int timeoutMsP);
bool Write(const char* bufferAddrP, unsigned int bufferLenP);
};
#endif // __IPTV_SOCKET_H