GComm  0.2.3
asio_protonet.hpp
1 /*
2  * Copyright (C) 2010 Codership Oy <info@codership.com>
3  */
4 
5 #ifndef GCOMM_ASIO_PROTONET_HPP
6 #define GCOMM_ASIO_PROTONET_HPP
7 
8 #include "gcomm/protonet.hpp"
9 #include "socket.hpp"
10 
11 #include "gu_monitor.hpp"
12 
13 #pragma GCC diagnostic ignored "-Weffc++"
14 #pragma GCC diagnostic ignored "-Wold-style-cast"
15 #include "asio.hpp"
16 #ifdef HAVE_ASIO_SSL_HPP
17 #include "asio/ssl.hpp"
18 #endif // HAVE_ASIO_SSL_HPP
19 
20 #include <vector>
21 #include <deque>
22 #include <list>
23 
24 namespace gcomm
25 {
26  class AsioProtonet;
27 }
28 
30 {
31 public:
32 
33  AsioProtonet(gu::Config& conf, int version = 0);
34  ~AsioProtonet();
35  void event_loop(const gu::datetime::Period& p);
36  void dispatch(const SocketId&,
37  const Datagram&,
38  const ProtoUpMeta&);
39  void interrupt();
40  SocketPtr socket(const gu::URI&);
41  gcomm::Acceptor* acceptor(const gu::URI&);
42  void enter();
43  void leave();
44  size_t mtu() const { return mtu_; }
45 
46 #ifdef HAVE_ASIO_SSL_HPP
47  std::string get_ssl_password() const;
48 #endif // HAVE_ASIO_SSL_HPP
49 
50 private:
51 
52  friend class AsioTcpSocket;
53  friend class AsioTcpAcceptor;
54  friend class AsioUdpSocket;
55  AsioProtonet(const AsioProtonet&);
56 
57  void handle_wait(const asio::error_code& ec);
58 
59  gu::RecursiveMutex mutex_;
60  gu::datetime::Date poll_until_;
61  asio::io_service io_service_;
62  asio::deadline_timer timer_;
63 #ifdef HAVE_ASIO_SSL_HPP
64  asio::ssl::context ssl_context_;
65 #endif /* HAVE_ASIO_SSL_HPP */
66  size_t mtu_;
67 
68  NetHeader::checksum_t checksum_;
69 };
70 
71 #endif // GCOMM_ASIO_PROTONET_HPP
Definition: protonet.hpp:37
Definition: asio_udp.hpp:19
Definition: asio_protonet.hpp:29
Definition: asio_tcp.hpp:84
Definition: asio_tcp.hpp:25
Definition: protolay.hpp:77
Definition: socket.hpp:72
Datagram container.
Definition: datagram.hpp:151