// excerpts from http://code.google.com/p/muduo/ // // Use of this source code is governed by a BSD-style license // that can be found in the License file. // // Author: Shuo Chen (chenshuo at chenshuo dot com) #ifndef MUDUO_NET_ACCEPTOR_H #define MUDUO_NET_ACCEPTOR_H #include #include #include "Channel.h" #include "Socket.h" namespace muduo { class EventLoop; class InetAddress; /// /// Acceptor of incoming TCP connections. /// class Acceptor : boost::noncopyable { public: typedef boost::function NewConnectionCallback; Acceptor(EventLoop* loop, const InetAddress& listenAddr); void setNewConnectionCallback(const NewConnectionCallback& cb) { newConnectionCallback_ = cb; } bool listenning() const { return listenning_; } void listen(); private: void handleRead(); EventLoop* loop_; Socket acceptSocket_; Channel acceptChannel_; NewConnectionCallback newConnectionCallback_; bool listenning_; }; } #endif // MUDUO_NET_ACCEPTOR_H