Kea  1.9.9-git
unix_domain_socket.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_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 
16 namespace isc {
17 namespace asiolink {
18 
21 public:
22  UnixDomainSocketError(const char* file, size_t line, const char* what) :
23  isc::Exception(file, line, what) { };
24 };
25 
26 class UnixDomainSocketImpl;
27 
30 class UnixDomainSocket : public IOSocket {
31 public:
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(IOService& 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 
85  void asyncSend(const void* data, const size_t length, const Handler& handler);
86 
95  size_t receive(void* data, size_t length);
96 
105  void asyncReceive(void* data, const size_t length, const Handler& handler);
106 
110  void shutdown();
111 
115  void cancel();
116 
120  void close();
121 
125  virtual boost::asio::local::stream_protocol::socket& getASIOSocket() const;
126 
127 private:
128 
130  boost::shared_ptr<UnixDomainSocketImpl> impl_;
131 
132 };
133 
134 } // end of namespace isc::asiolink
135 } // end of namespace isc
136 
137 #endif // UNIX_DOMAIN_SOCKET_H
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.