Kea: unix_domain_socket_acceptor.h Source File

| Kea 1.5.0

unix_domain_socket_acceptor.h
Go to the documentation of this file.
1 // Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7 #ifndef UNIX_DOMAIN_SOCKET_ACCEPTOR_H
8 #define UNIX_DOMAIN_SOCKET_ACCEPTOR_H
9
10 #ifndef BOOST_ASIO_HPP
11 #error "asio.hpp must be included before including this, see asiolink.h as to why"
12 #endif
13
14 #include <asiolink/io_acceptor.h>
15 #include <asiolink/unix_domain_socket.h>
16 #include <functional>
17
18 namespace isc {
19 namespace asiolink {
20
25 class UnixDomainSocketAcceptor : public IOAcceptor<boost::asio::local::stream_protocol,
26 std::function<void(const boost::system::error_code&)> > {
27 public:
28
30 typedef std::function<void(const boost::system::error_code&)> AcceptHandler;
31
35 explicit UnixDomainSocketAcceptor(IOService& io_service)
36 : IOAcceptor<boost::asio::local::stream_protocol,
37 std::function<void(const boost::system::error_code&)> >(io_service) {
38 }
39
43 virtual int getProtocol() const final {
44 return (AF_LOCAL);
45 }
46
57 void asyncAccept(const UnixDomainSocket& socket, const AcceptHandler& callback) {
58 asyncAcceptInternal(socket, callback);
59 }
60 };
61
62 } // end of namespace isc::asiolink
63 } // end of namespace isc
64
65 #endif // UNIX_DOMAIN_SOCKET_ACCEPTOR_H
isc::asiolink::UnixDomainSocketAcceptor::AcceptHandler
std::function< void(const boost::system::error_code &)> AcceptHandler
Callback type used in call to UnixDomainSocketAcceptor::asyncAccept.
Definition: unix_domain_socket_acceptor.h:30
isc::asiolink::IOAcceptor< boost::asio::local::stream_protocol, std::function< void(const boost::system::error_code &)> >::asyncAcceptInternal
void asyncAcceptInternal(const SocketType &socket, const std::function< void(const boost::system::error_code &)> &callback)
Asynchronously accept new connection.
Definition: io_acceptor.h:121
isc::asiolink::IOService
The IOService class is a wrapper for the ASIO io_service class.
Definition: io_service.h:31
unix_domain_socket.h
boost
Definition: io_service.h:12
isc::asiolink::UnixDomainSocketAcceptor::asyncAccept
void asyncAccept(const UnixDomainSocket &socket, const AcceptHandler &callback)
Asynchronously accept new connection.
Definition: unix_domain_socket_acceptor.h:57
isc::asiolink::UnixDomainSocketAcceptor::UnixDomainSocketAcceptor
UnixDomainSocketAcceptor(IOService &io_service)
Constructor.
Definition: unix_domain_socket_acceptor.h:35
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
isc::asiolink::UnixDomainSocketAcceptor
Implements acceptor service for UnixDomainSocket.
Definition: unix_domain_socket_acceptor.h:26
isc::asiolink::UnixDomainSocket
Represents unix domain socket implemented in terms of boost asio.
Definition: unix_domain_socket.h:30
asiolink
A wrapper interface for the ASIO library.
isc::asiolink::IOAcceptor
Base class for acceptor services in Kea.
Definition: io_acceptor.h:34
isc::asiolink::UnixDomainSocketAcceptor::getProtocol
virtual int getProtocol() const final
Returns the transport protocol of the socket.
Definition: unix_domain_socket_acceptor.h:43
io_acceptor.h