0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
IOHandlerRaw.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef AsyncComm_IOHandlerRaw_h
28 #define AsyncComm_IOHandlerRaw_h
29 
30 #include "CommBuf.h"
31 #include "IOHandler.h"
32 #include "RawSocketHandler.h"
33 
34 #include <Common/Error.h>
35 
36 namespace Hypertable {
37 
40 
42  class IOHandlerRaw : public IOHandler {
43 
44  public:
45 
52  IOHandlerRaw(int sd, const InetAddr &addr, RawSocketHandler *rhp)
53  : IOHandler(sd), m_handler(rhp) {
54  m_socket_internally_created = false;
55  memcpy(&m_addr, &addr, sizeof(InetAddr));
56  }
57 
60  virtual ~IOHandlerRaw() {
62  }
63 
76  bool handle_event(struct pollfd *event,
77  ClockT::time_point arrival_time) override;
78 
79 #if defined(__APPLE__) || defined(__FreeBSD__)
80  bool handle_event(struct kevent *event,
93  ClockT::time_point arrival_time) override;
94 #elif defined(__linux__)
95  bool handle_event(struct epoll_event *event,
110  ClockT::time_point arrival_time) override;
111 #elif defined(__sun__)
112  bool handle_event(port_event_t *event,
127  ClockT::time_point arrival_time) override;
128 #else
130 #endif
131 
140  void update_poll_interest();
141 
142  private:
143 
146 
147  };
149 }
150 
151 #endif // AsyncComm_IOHandlerRaw_h
virtual void deregister(int sd)=0
Deregister handler for a given socket.
Declarations for RawSocketHandler.
chrono::time_point< fast_clock > time_point
Definition: fast_clock.h:42
Abstract base class for application raw socket handlers registered with AsyncComm.
void update_poll_interest()
Updates polling interest for socket.
IOHandlerRaw(int sd, const InetAddr &addr, RawSocketHandler *rhp)
Constructor.
Definition: IOHandlerRaw.h:52
RawSocketHandler * m_handler
Raw socket handler.
Definition: IOHandlerRaw.h:145
Encapsulate an internet address.
Definition: InetAddr.h:66
virtual ~IOHandlerRaw()
Destructor.
Definition: IOHandlerRaw.h:60
Base class for socket descriptor I/O handlers.
Definition: IOHandler.h:76
int m_sd
Socket descriptor.
Definition: IOHandler.h:466
Hypertable definitions
Declarations for CommBuf.
InetAddr m_addr
Handler socket address.
Definition: IOHandler.h:457
Error codes, Exception handling, error logging.
bool handle_event(struct pollfd *event, ClockT::time_point arrival_time) override
Handle poll() interface events.
Definition: IOHandlerRaw.cc:59
I/O handler for raw sockets.
Definition: IOHandlerRaw.h:42
Declarations for IOHandler.