Kea 3.3.4
unix_domain_socket.h
Go to the documentation of this file.
1// Copyright (C) 2017-2026 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_H
8#define UNIX_DOMAIN_SOCKET_H
9
11#include <asiolink/io_service.h>
12#include <asiolink/io_socket.h>
13#include <boost/shared_ptr.hpp>
14#include <functional>
15#include <string>
16
17namespace isc {
18namespace asiolink {
19
22public:
23 UnixDomainSocketError(const char* file, size_t line, const char* what) :
24 isc::Exception(file, line, what) { }
25};
26
27class UnixDomainSocketImpl;
28
31class UnixDomainSocket : public IOSocket {
32public:
33
35 typedef std::function<void(const boost::system::error_code&)> ConnectHandler;
36
39 typedef std::function<void(const boost::system::error_code&, size_t)> Handler;
40
45 explicit UnixDomainSocket(const IOServicePtr& io_service);
46
48 virtual int getNative() const;
49
51 virtual int getProtocol() const;
52
58 void connect(const std::string& path);
59
67 void asyncConnect(const std::string& path, const ConnectHandler& handler);
68
76 size_t write(const void* data, size_t length);
77
89 void asyncSend(const void* data, const size_t length, const Handler& handler);
90
99 size_t receive(void* data, size_t length);
100
109 void asyncReceive(void* data, const size_t length, const Handler& handler);
110
114 void shutdown();
115
119 void cancel();
120
124 void close();
125
129 virtual boost::asio::local::stream_protocol::socket& getASIOSocket() const;
130
131private:
132
134 boost::shared_ptr<UnixDomainSocketImpl> impl_;
135
136};
137
138} // end of namespace isc::asiolink
139} // end of namespace isc
140
141#endif // UNIX_DOMAIN_SOCKET_H
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Defines the logger used by the top-level component of kea-lfc.