Kea: unix_domain_socket_acceptor.h Source File

| Kea 3.2.0-git

unix_domain_socket_acceptor.h
Go to the documentation of this file.
1// Copyright (C) 2017-2024 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
18namespace isc {
19namespace asiolink {
20
25 class UnixDomainSocketAcceptor : public IOAcceptor<boost::asio::local::stream_protocol,
26 std::function<void(const boost::system::error_code&)> > {
27public:
28
30 typedef std::function<void(const boost::system::error_code&)> AcceptHandler;
31
35 explicit UnixDomainSocketAcceptor(const IOServicePtr& 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::IOAcceptor< boost::asio::local::stream_protocol, std::function< void(const boost::system::error_code &)> >::IOAcceptor
IOAcceptor(const IOServicePtr &io_service)
Definition io_acceptor.h:40
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)
Definition io_acceptor.h:117
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(const IOServicePtr &io_service)
Constructor.
Definition unix_domain_socket_acceptor.h:35
isc::asiolink::UnixDomainSocketAcceptor::getProtocol
virtual int getProtocol() const final
Returns the transport protocol of the socket.
Definition unix_domain_socket_acceptor.h:43
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::UnixDomainSocket
Represents unix domain socket implemented in terms of boost asio.
Definition unix_domain_socket.h:30
io_acceptor.h
isc::asiolink
Definition addr_utilities.cc:170
isc::asiolink::IOServicePtr
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
Definition io_service.h:35
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
unix_domain_socket.h