Kea 3.3.1
unix_domain_socket.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_H
8#define UNIX_DOMAIN_SOCKET_H
9
10#include <asiolink/io_service.h>
11#include <asiolink/io_socket.h>
12#include <boost/shared_ptr.hpp>
13#include <functional>
14#include <string>
15
16namespace isc {
17namespace asiolink {
18
21public:
22 UnixDomainSocketError(const char* file, size_t line, const char* what) :
23 isc::Exception(file, line, what) { }
24};
25
26class UnixDomainSocketImpl;
27
30class UnixDomainSocket : public IOSocket {
31public:
32
34 typedef std::function<void(const boost::system::error_code&)> ConnectHandler;
35
38 typedef std::function<void(const boost::system::error_code&, size_t)> Handler;
39
44 explicit UnixDomainSocket(const IOServicePtr& io_service);
45
47 virtual int getNative() const;
48
50 virtual int getProtocol() const;
51
57 void connect(const std::string& path);
58
66 void asyncConnect(const std::string& path, const ConnectHandler& handler);
67
75 size_t write(const void* data, size_t length);
76
88 void asyncSend(const void* data, const size_t length, const Handler& handler);
89
98 size_t receive(void* data, size_t length);
99
108 void asyncReceive(void* data, const size_t length, const Handler& handler);
109
113 void shutdown();
114
118 void cancel();
119
123 void close();
124
128 virtual boost::asio::local::stream_protocol::socket& getASIOSocket() const;
129
130private:
131
133 boost::shared_ptr<UnixDomainSocketImpl> impl_;
134
135};
136
137} // end of namespace isc::asiolink
138} // end of namespace isc
139
140#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.