File: socketserver.h

package info (click to toggle)
imms 3.0.2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 920 kB
  • ctags: 1,195
  • sloc: cpp: 7,224; ansic: 1,872; sh: 186; makefile: 127
file content (33 lines) | stat: -rw-r--r-- 714 bytes parent folder | download | duplicates (2)
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
#ifndef __SOCKETSERVER_H
#define __SOCKETSERVER_H

#include <string>

#include "immsconf.h"
#include "giosocket.h"

using std::string;

class SocketListenerBase
{
public:
    SocketListenerBase(const string &sockpath);
    virtual ~SocketListenerBase();

    static gboolean incoming_connection_helper(GIOChannel *source,
            GIOCondition condition, gpointer data);

    virtual void incoming_connection(int fd) = 0;
protected:
    GIOChannel *listener;
};

template <typename Connection>
class SocketListener : public SocketListenerBase
{
public:
    SocketListener(const string &sockpath) : SocketListenerBase(sockpath) {};
    virtual void incoming_connection(int fd) { new Connection(fd); }
};

#endif