| Kea 3.0.2-git

tcp_acceptor.h
Go to the documentation of this file.
1// Copyright (C) 2016-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 TCP_ACCEPTOR_H
8#define TCP_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/io_service.h>
16#include <asiolink/io_socket.h>
17#include <asiolink/tcp_endpoint.h>
18#include <asiolink/tcp_socket.h>
19#include <boost/shared_ptr.hpp>
20#include <netinet/in.h>
21
22 namespace isc {
23 namespace asiolink {
24
31 template<typename C>
32 class TCPAcceptor : public IOAcceptor<boost::asio::ip::tcp, C> {
33 public:
34
38 explicit TCPAcceptor(const IOServicePtr& io_service)
39 : IOAcceptor<boost::asio::ip::tcp, C>(io_service) {
40 }
41
45 virtual int getProtocol() const final {
46 return (IPPROTO_TCP);
47 }
48
59 template<typename SocketCallback>
60 void asyncAccept(const TCPSocket<SocketCallback>& socket, C& callback) {
61 IOAcceptor<boost::asio::ip::tcp, C>::asyncAcceptInternal(socket, callback);
62 }
63};
64
65
66} // namespace asiolink
67} // namespace isc
68
69#endif
isc::asiolink::IOAcceptor< boost::asio::ip::tcp, C >::IOAcceptor
IOAcceptor(const IOServicePtr &io_service)
Definition io_acceptor.h:40
isc::asiolink::IOAcceptor::asyncAcceptInternal
void asyncAcceptInternal(const SocketType &socket, const CallbackType &callback)
Asynchronously accept new connection.
Definition io_acceptor.h:117
isc::asiolink::TCPAcceptor::getProtocol
virtual int getProtocol() const final
Returns protocol of the socket.
Definition tcp_acceptor.h:45
isc::asiolink::TCPAcceptor::TCPAcceptor
TCPAcceptor(const IOServicePtr &io_service)
Constructor.
Definition tcp_acceptor.h:38
isc::asiolink::TCPAcceptor::asyncAccept
void asyncAccept(const TCPSocket< SocketCallback > &socket, C &callback)
Asynchronously accept new connection.
Definition tcp_acceptor.h:60
isc::asiolink::TCPSocket
The TCPSocket class is a concrete derived class of IOAsioSocket that represents a TCP socket.
Definition tcp_socket.h:48
io_acceptor.h
io_service.h
io_socket.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:28
isc::tcp
Definition mt_tcp_listener_mgr.cc:23
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
tcp_endpoint.h
tcp_socket.h