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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
//***************************************************************************
// Group VDR/GraphTFT
// File tcpchannel.h
// Date 31.10.06
// This code is distributed under the terms and conditions of the
// GNU GENERAL PUBLIC LICENSE. See the file COPYING for details.
// (c) 2006-2014 Jörg Wendel
//--------------------------------------------------------------------------
// Class TcpChannel
//***************************************************************************
#ifndef __GTFT_TCPCHANNEL_H__
#define __GTFT_TCPCHANNEL_H__
//***************************************************************************
// Class TcpChannel
//***************************************************************************
class TcpChannel
{
public:
// declarations
enum Errors
{
errChannel = -100,
errUnknownHostname,
errBindAddressFailed,
errAcceptFailed,
errListenFailed,
errConnectFailed,
errIOError,
errConnectionClosed,
errInvalidEndpoint,
errOpenEndpointFailed,
// Warnungen
wrnNoEventPending,
errUnexpectedEvent,
wrnChannelBlocked,
wrnNoConnectIndication,
wrnNoResponseFromServer,
wrnNoDataAvaileble,
wrnSysInterrupt,
wrnTimeout
};
#pragma pack(1)
struct Header
{
int command;
int size;
};
#pragma pack()
// object
TcpChannel(int aTimeout = 2, int aHandle = 0);
~TcpChannel();
// api function
int openLstn(unsigned short aPort, const char* aLocalHost = 0);
int open(unsigned short aPort, const char* aHost);
int close();
int listen(TcpChannel*& child);
int look(int aTimeout);
int read(char* buf, int bufLen);
int write(int command, const char* buf = 0, int bufLen = 0);
int isConnected() { return handle != 0; }
private:
int checkErrno();
int handle;
unsigned short port;
char localHost[100];
char remoteHost[100];
long localAddr;
long remoteAddr;
long timeout;
int lookAheadChar;
int lookAhead;
int nTtlReceived;
int nTtlSent;
#ifdef VDR_PLUGIN
cMutex _mutex;
#endif
};
//***************************************************************************
#endif // __GTFT_TCPCHANNEL_H__
|