Kea 2.5.8
watch_socket.h
Go to the documentation of this file.
1// Copyright (C) 2014-2015 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;
54 static const uint32_t MARKER = 0xDEADBEEF;
55
61
65 virtual ~WatchSocket();
66
76 void markReady();
77
87 bool isReady();
88
99 void clearReady();
100
108 int getSelectFd();
109
119 bool closeSocket(std::string& error_string);
120
121private:
122
127 void closeSocket();
128
130 int source_;
131
134 int sink_;
135};
136
138typedef boost::shared_ptr<WatchSocket> WatchSocketPtr;
139
140} // namespace isc::util
141} // namespace isc
142
143#endif
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Exception thrown if an error occurs during IO source open.
Definition: watch_socket.h:23
WatchSocketError(const char *file, size_t line, const char *what)
Definition: watch_socket.h:25
Provides an IO "ready" semaphore for use with select() or poll() WatchSocket exposes a single open fi...
Definition: watch_socket.h:47
static const int SOCKET_NOT_VALID
Value used to signify an invalid descriptor.
Definition: watch_socket.h:50
static const uint32_t MARKER
Value written to the source when marking the socket as ready.
Definition: watch_socket.h:54
void clearReady()
Clears the socket's ready to read marker.
WatchSocket()
Constructor.
Definition: watch_socket.cc:28
bool closeSocket(std::string &error_string)
Closes the descriptors associated with the socket.
virtual ~WatchSocket()
Destructor.
Definition: watch_socket.cc:59
int getSelectFd()
Returns the file descriptor to use to monitor the socket.
bool isReady()
Returns true the if socket is marked as ready.
Definition: watch_socket.cc:89
void markReady()
Marks the select-fd as ready to read.
Definition: watch_socket.cc:64
boost::shared_ptr< WatchSocket > WatchSocketPtr
Defines a smart pointer to an instance of a WatchSocket.
Definition: watch_socket.h:138
Defines the logger used by the top-level component of kea-lfc.