diff options
Diffstat (limited to 'server/component.c')
-rw-r--r-- | server/component.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/server/component.c b/server/component.c index 61e7c6b..1a584b5 100644 --- a/server/component.c +++ b/server/component.c @@ -1,50 +1,48 @@ /* - * $Id: component.c,v 1.2 2005/02/08 17:22:35 lordjaxom Exp $ + * $Id: component.c,v 1.3 2005/05/09 20:22:29 lordjaxom Exp $ */ #include "server/component.h" #include "server/connection.h" -#include <vdr/tools.h> -#include <string.h> -#include <errno.h> - cServerComponent::cServerComponent(const char *Protocol, const char *ListenIp, - uint ListenPort) { - m_Protocol = Protocol; - m_ListenIp = ListenIp; - m_ListenPort = ListenPort; + uint ListenPort): + m_Protocol(Protocol), + m_ListenIp(ListenIp), + m_ListenPort(ListenPort) +{ } -cServerComponent::~cServerComponent() { +cServerComponent::~cServerComponent() +{ } -bool cServerComponent::Init(void) { +bool cServerComponent::Initialize(void) +{ if (!m_Listen.Listen(m_ListenIp, m_ListenPort, 5)) { - esyslog("Streamdev: Couldn't listen (%s) %s:%d: %s", m_Protocol, m_ListenIp, - m_ListenPort, strerror(errno)); + 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::Exit(void) { +void cServerComponent::Destruct(void) +{ m_Listen.Close(); } -cServerConnection *cServerComponent::CanAct(const cTBSelect &Select) { - if (Select.CanRead(m_Listen)) { - cServerConnection *client = NewConnection(); - 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): %s", m_Protocol, - strerror(errno)); - delete client; - } +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; } |