vdr-plugin-streamdev/server/component.h

52 lines
1.4 KiB
C
Raw Permalink Normal View History

2004-12-30 23:43:55 +01:00
/*
* $Id: component.h,v 1.2.2.1 2009/02/13 10:39:42 schmirl Exp $
2004-12-30 23:43:55 +01:00
*/
#ifndef VDR_STREAMDEV_SERVERS_COMPONENT_H
#define VDR_STREAMDEV_SERVERS_COMPONENT_H
#include "tools/socket.h"
#include "tools/select.h"
#include <vdr/tools.h>
class cServerConnection;
/* Basic TCP listen server, all functions virtual if a derivation wants to do
things different */
class cServerComponent: public cListObject {
private:
const char *m_Protocol;
cTBSocket m_Listen;
2004-12-30 23:43:55 +01:00
const char *m_ListenIp;
uint m_ListenPort;
2005-05-09 22:22:29 +02:00
protected:
/* Returns a new connection object for Accept() */
virtual cServerConnection *NewClient(void) = 0;
2004-12-30 23:43:55 +01:00
public:
cServerComponent(const char *Protocol, const char *ListenIp, uint ListenPort, int Type = SOCK_STREAM, int IpProto = 0);
2004-12-30 23:43:55 +01:00
virtual ~cServerComponent();
/* Starts listening on the specified Port, override if you want to do things
different */
2005-05-09 22:22:29 +02:00
virtual bool Initialize(void);
2004-12-30 23:43:55 +01:00
/* Stops listening, override if you want to do things different */
2005-05-09 22:22:29 +02:00
virtual void Destruct(void);
2004-12-30 23:43:55 +01:00
2005-05-09 22:22:29 +02:00
/* Get the listening socket's file number */
virtual int Socket(void) const { return (int)m_Listen; }
2004-12-30 23:43:55 +01:00
2005-05-09 22:22:29 +02:00
/* Adds the listening socket to the Select object */
virtual void Add(cTBSelect &Select) const { Select.Add(m_Listen); }
2004-12-30 23:43:55 +01:00
2005-05-09 22:22:29 +02:00
/* Accepts the connection on a NewClient() object and calls the
Welcome() on it, override if you want to do things different */
virtual cServerConnection *Accept(void);
2004-12-30 23:43:55 +01:00
};
#endif // VDR_STREAMDEV_SERVERS_COMPONENT_H