File: Multiplexer.H

package info (click to toggle)
dxpc 3.9.2-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,164 kB
  • ctags: 1,252
  • sloc: cpp: 12,036; sh: 2,823; makefile: 77
file content (58 lines) | stat: -rw-r--r-- 1,239 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
58
#ifndef Multiplexer_H
# define Multiplexer_H

# include <sys/types.h>
# ifdef _AIX
#  include <sys/select.h>
# endif/* _AIX */

# include "ProxyReadBuffer.H"
# include "EncodeBuffer.H"
# include "constants.H"


class Channel;



class Multiplexer
{
  public:
    Multiplexer(int proxyFD);
      virtual ~ Multiplexer();

    void setSelectFDs(fd_set *, unsigned int &max);
    int handleSelect(int fd);

    virtual void createNewConnection(int clientFD) = 0;

  protected:

    // codes used for control messages in proxy-to-proxy protocol
    enum ControlCode
    {
        CTRL_NEW_CONNECTION, CTRL_DROP_CONNECTION,
        CTRL_SWITCH_CONNECTION
    };

    virtual int createNewConnectionFromProxy(int channelID) = 0;

    virtual int channelIDToFD(int channelID) const = 0;
    virtual int fdToChannelID(int fd) const = 0;
    virtual void cleanupChannelFDMapping(int channelFD) = 0;

    // Objects used to read data sent from peer proxy
    const int proxyFD_;
    ProxyReadBuffer proxyReadBuffer_;
    int proxyInputChannel_;

    // Objects used to send data to peer proxy
    EncodeBuffer encodeBuffer_;
    int proxyOutputChannel_;

    // X connections
    Channel *channels_[MAX_CONNECTIONS];
};


#endif /* Multiplexer_H */