summaryrefslogtreecommitdiff
path: root/tcpchannel.h
diff options
context:
space:
mode:
authorhorchi <vdr@jwendel.de>2017-03-05 16:47:41 +0100
committerhorchi <vdr@jwendel.de>2017-03-05 16:47:41 +0100
commit22ffee20bbacbc3378e4ba0df5b7f0c3daaeffc0 (patch)
treede46c945c62d43d1febb027b5bfa075e58c5b69a /tcpchannel.h
downloadvdr-plugin-graphtftng-0.6.16.tar.gz
vdr-plugin-graphtftng-0.6.16.tar.bz2
Diffstat (limited to 'tcpchannel.h')
-rw-r--r--tcpchannel.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/tcpchannel.h b/tcpchannel.h
new file mode 100644
index 0000000..bf7ca1c
--- /dev/null
+++ b/tcpchannel.h
@@ -0,0 +1,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__