-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtcpchannel.h
92 lines (73 loc) · 2.37 KB
/
tcpchannel.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//***************************************************************************
// 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-2008 Jörg Wendel
//--------------------------------------------------------------------------
// Class TcpChannel
//***************************************************************************
#ifndef __GTFT_TCPCHANNEL_H__
#define __GTFT_TCPCHANNEL_H__
#include <vdr/thread.h>
//***************************************************************************
// Class TcpChannel
//***************************************************************************
class TcpChannel
{
public:
enum Errors
{
errChannel = -100,
errUnknownHostname, // 99
errBindAddressFailed, // 98
errAcceptFailed,
errListenFailed,
errConnectFailed, // 95
errIOError, // 94
errConnectionClosed, // 93
errInvalidEndpoint,
errOpenEndpointFailed, // 91
// Warnungen
wrnNoEventPending, // 90
errUnexpectedEvent, // 89
wrnChannelBlocked, // 88
wrnNoConnectIndication, // 87
wrnNoResponseFromServer, // 86
wrnNoDataAvaileble, // 85
wrnSysInterrupt, // 84
wrnTimeout // 83
};
#pragma pack(1)
struct Header
{
int command;
int size;
};
#pragma pack()
TcpChannel(int aTimeout = 2, int aHandle = 0);
~TcpChannel();
int open(unsigned short aPort, const char* aLocalHost = 0);
int close();
int listen(TcpChannel*& child);
int look(int aTimeout = 0);
int read(char* buf, int bufLen);
int write(int command, const char* buf = 0, int bufLen = 0);
int isConnected() { return handle != 0; }
int getHandle() { return handle; }
private:
int checkErrno();
// data
int lookAheadChar;
int lookAhead;
int handle;
unsigned short port;
long localAddr;
long nTtlSent;
long nTtlReceived;
long timeout; // for read/write
cMutex _mutex;
};
//***************************************************************************
#endif // __GTFT_TCPCHANNEL_H__