diff options
author | horchi <vdr@jwendel.de> | 2017-03-05 16:47:41 +0100 |
---|---|---|
committer | horchi <vdr@jwendel.de> | 2017-03-05 16:47:41 +0100 |
commit | 22ffee20bbacbc3378e4ba0df5b7f0c3daaeffc0 (patch) | |
tree | de46c945c62d43d1febb027b5bfa075e58c5b69a /graphtft-fe/tcpchannel.h | |
download | vdr-plugin-graphtftng-0.6.16.tar.gz vdr-plugin-graphtftng-0.6.16.tar.bz2 |
Diffstat (limited to 'graphtft-fe/tcpchannel.h')
-rw-r--r-- | graphtft-fe/tcpchannel.h | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/graphtft-fe/tcpchannel.h b/graphtft-fe/tcpchannel.h new file mode 100644 index 0000000..c7b5881 --- /dev/null +++ b/graphtft-fe/tcpchannel.h @@ -0,0 +1,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__ |