blob: 8703348057d3c49de21f7801c1f20c33b5030330 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/*
* $Id: component.h,v 1.2 2005/05/09 20:22:29 lordjaxom Exp $
*/
#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:
cTBSocket m_Listen;
const char *m_Protocol;
const char *m_ListenIp;
uint m_ListenPort;
protected:
/* Returns a new connection object for Accept() */
virtual cServerConnection *NewClient(void) = 0;
public:
cServerComponent(const char *Protocol, const char *ListenIp, uint ListenPort);
virtual ~cServerComponent();
/* Starts listening on the specified Port, override if you want to do things
different */
virtual bool Initialize(void);
/* Stops listening, override if you want to do things different */
virtual void Destruct(void);
/* Get the listening socket's file number */
virtual int Socket(void) const { return (int)m_Listen; }
/* Adds the listening socket to the Select object */
virtual void Add(cTBSelect &Select) const { Select.Add(m_Listen); }
/* 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);
};
#endif // VDR_STREAMDEV_SERVERS_COMPONENT_H
|