Kea 3.1.7
watch_socket.h
Go to the documentation of this file.
1// Copyright (C) 2014-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 WATCH_SOCKET_H
8#define WATCH_SOCKET_H
9
11
13#include <boost/noncopyable.hpp>
14#include <boost/shared_ptr.hpp>
15
16#include <stdint.h>
17#include <string>
18
19namespace isc {
20namespace util {
21
24public:
25 WatchSocketError(const char* file, size_t line, const char* what) :
26 isc::Exception(file, line, what) { }
27};
28
47class WatchSocket : public boost::noncopyable {
48public:
50 static const int SOCKET_NOT_VALID /* = -1 */;
51
55 static const uint32_t MARKER /* = 0xDEADBEEF */;
56
62
66 virtual ~WatchSocket();
67
77 void markReady();
78
88 bool isReady();
89
100 void clearReady();
101
109 int getSelectFd();
110
120 bool closeSocket(std::string& error_string);
121
122private:
123
128 void closeSocket();
129
131 int source_;
132
135 int sink_;
136};
137
139typedef boost::shared_ptr<WatchSocket> WatchSocketPtr;
140
141} // namespace isc::util
142} // namespace isc
143
144#endif
This is a base class for exceptions thrown from the DNS library module.
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.
WatchSocketError(const char *file, size_t line, const char *what)
static const int SOCKET_NOT_VALID
Value used to signify an invalid descriptor.
static const uint32_t MARKER
Value written to the source when marking the socket as ready.
void clearReady()
Clears the socket's ready to read marker.
WatchSocket()
Constructor.
bool closeSocket(std::string &error_string)
Closes the descriptors associated with the socket.
virtual ~WatchSocket()
Destructor.
int getSelectFd()
Returns the file descriptor to use to monitor the socket.
bool isReady()
Returns true the if socket is marked as ready.
void markReady()
Marks the select-fd as ready to read.
boost::shared_ptr< WatchSocket > WatchSocketPtr
Defines a smart pointer to an instance of a WatchSocket.
Defines the logger used by the top-level component of kea-lfc.