summaryrefslogtreecommitdiff
path: root/vdr-androvdr/sock.h
diff options
context:
space:
mode:
authorbju <bju@maxi.fritz.box>2011-03-19 15:54:21 +0100
committerbju <bju@maxi.fritz.box>2011-03-19 15:54:21 +0100
commitb4558f9dac4977c6ac933f52fc98b9eea9dfdbca (patch)
tree2f0c36309c44235d4bd8121d82271cd16bcd5348 /vdr-androvdr/sock.h
downloadvdr-manager-b4558f9dac4977c6ac933f52fc98b9eea9dfdbca.tar.gz
vdr-manager-b4558f9dac4977c6ac933f52fc98b9eea9dfdbca.tar.bz2
First revision
Diffstat (limited to 'vdr-androvdr/sock.h')
-rw-r--r--vdr-androvdr/sock.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/vdr-androvdr/sock.h b/vdr-androvdr/sock.h
new file mode 100644
index 0000000..260efed
--- /dev/null
+++ b/vdr-androvdr/sock.h
@@ -0,0 +1,63 @@
+/*
+ * extendes sockets
+ */
+
+#ifndef _VDRMON_SOCK
+#define _VDRMON_SOCK
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <string>
+
+using namespace std;
+
+class cVdrmanagerSocket
+{
+protected:
+ int sock;
+ const char * password;
+protected:
+ cVdrmanagerSocket();
+public:
+ virtual ~cVdrmanagerSocket();
+ void Close();
+ int GetSocket();
+ bool MakeDontBlock();
+ const char * GetPassword();
+};
+
+class cVdrmanagerClientSocket : public cVdrmanagerSocket
+{
+private:
+ string readbuf;
+ string writebuf;
+ bool disconnected;
+ int client;
+ bool login;
+public:
+ cVdrmanagerClientSocket(const char * password);
+ virtual ~cVdrmanagerClientSocket();
+ bool Attach(int fd);
+ bool IsLineComplete();
+ bool GetLine(string& line);
+ bool PutLine(string line);
+ bool Read();
+ bool Disconnected();
+ void Disconnect();
+ bool Flush();
+ int GetClientId();
+ bool WritePending();
+ bool IsLoggedIn();
+ void SetLoggedIn();
+};
+
+class cVdrmanagerServerSocket : public cVdrmanagerSocket
+{
+public:
+ cVdrmanagerServerSocket();
+ virtual ~cVdrmanagerServerSocket();
+ bool Create(int port, const char * password);
+ cVdrmanagerClientSocket * Accept();
+};
+
+#endif