-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathacceptor.hpp
43 lines (27 loc) · 847 Bytes
/
acceptor.hpp
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
#pragma once
#include <memory>
#include "handler.hpp"
#include "reactor.hpp"
class Acceptor;
typedef std::shared_ptr<Acceptor> AcceptorPtr;
class SockStream;
class Acceptor : public Handler
{
private:
Acceptor(ReactorPtr acceptor_reactor, ReactorPtr session_reactor);
public:
~Acceptor();
Acceptor& operator=( const Acceptor & ) = delete;
Acceptor( const Acceptor & ) = delete;
static AcceptorPtr create(ReactorPtr acceptor_reactor, ReactorPtr session_reactor) {return AcceptorPtr(new Acceptor(acceptor_reactor, session_reactor)); }
void open();
void accept(SockStream& stream);
void close();
State handle_input();
int get_handle() const { return socket_; }
private:
int socket_;
ReactorPtr acceptor_reactor_;
ReactorPtr session_reactor_;
unsigned int timeout_;
};