summaryrefslogtreecommitdiff
path: root/server/component.c
diff options
context:
space:
mode:
authorFrank Schmirler <schmirl@puter.linogate.de>2010-12-02 08:53:01 +0100
committerFrank Schmirler <schmirl@puter.linogate.de>2010-12-02 08:53:01 +0100
commit5e30711bfdb28085234a5ef6da4f4e44305ac3e4 (patch)
treed15809d23eeeed7fda55d9450b1af7c99d6eb5d6 /server/component.c
downloadvdr-plugin-streamdev-5e30711bfdb28085234a5ef6da4f4e44305ac3e4.tar.gz
vdr-plugin-streamdev-5e30711bfdb28085234a5ef6da4f4e44305ac3e4.tar.bz2
Snapshot 2007-03-20
Diffstat (limited to 'server/component.c')
-rw-r--r--server/component.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/server/component.c b/server/component.c
new file mode 100644
index 0000000..1a584b5
--- /dev/null
+++ b/server/component.c
@@ -0,0 +1,48 @@
+/*
+ * $Id: component.c,v 1.3 2005/05/09 20:22:29 lordjaxom Exp $
+ */
+
+#include "server/component.h"
+#include "server/connection.h"
+
+cServerComponent::cServerComponent(const char *Protocol, const char *ListenIp,
+ uint ListenPort):
+ m_Protocol(Protocol),
+ m_ListenIp(ListenIp),
+ m_ListenPort(ListenPort)
+{
+}
+
+cServerComponent::~cServerComponent()
+{
+}
+
+bool cServerComponent::Initialize(void)
+{
+ if (!m_Listen.Listen(m_ListenIp, m_ListenPort, 5)) {
+ esyslog("Streamdev: Couldn't listen (%s) %s:%d: %m",
+ m_Protocol, m_ListenIp, m_ListenPort);
+ return false;
+ }
+ isyslog("Streamdev: Listening (%s) on port %d", m_Protocol, m_ListenPort);
+ return true;
+}
+
+void cServerComponent::Destruct(void)
+{
+ m_Listen.Close();
+}
+
+cServerConnection *cServerComponent::Accept(void)
+{
+ cServerConnection *client = NewClient();
+ if (client->Accept(m_Listen)) {
+ isyslog("Streamdev: Accepted new client (%s) %s:%d", m_Protocol,
+ client->RemoteIp().c_str(), client->RemotePort());
+ return client;
+ } else {
+ esyslog("Streamdev: Couldn't accept (%s): %m", m_Protocol);
+ delete client;
+ }
+ return NULL;
+}