libzmq  master
ZeroMQ C++ Core Engine (LIBZMQ)
pgm_sender.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
3 
4  This file is part of libzmq, the ZeroMQ core engine in C++.
5 
6  libzmq is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License (LGPL) as published
8  by the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  As a special exception, the Contributors give you permission to link
12  this library with independent modules to produce an executable,
13  regardless of the license terms of these independent modules, and to
14  copy and distribute the resulting executable under terms of your choice,
15  provided that you also meet, for each linked independent module, the
16  terms and conditions of the license of that module. An independent
17  module is a module which is not derived from or based on this library.
18  If you modify this library, you must extend this exception to your
19  version of the library.
20 
21  libzmq is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
24  License for more details.
25 
26  You should have received a copy of the GNU Lesser General Public License
27  along with this program. If not, see <http://www.gnu.org/licenses/>.
28 */
29 
30 #ifndef __ZMQ_PGM_SENDER_HPP_INCLUDED__
31 #define __ZMQ_PGM_SENDER_HPP_INCLUDED__
32 
33 #include "platform.hpp"
34 
35 #if defined ZMQ_HAVE_OPENPGM
36 
37 #ifdef ZMQ_HAVE_WINDOWS
38 #include "windows.hpp"
39 #endif
40 
41 #include "stdint.hpp"
42 #include "io_object.hpp"
43 #include "i_engine.hpp"
44 #include "options.hpp"
45 #include "pgm_socket.hpp"
46 #include "v1_encoder.hpp"
47 #include "msg.hpp"
48 
49 namespace zmq
50 {
51 
52  class io_thread_t;
53  class session_base_t;
54 
55  class pgm_sender_t : public io_object_t, public i_engine
56  {
57 
58  public:
59 
60  pgm_sender_t (zmq::io_thread_t *parent_, const options_t &options_);
61  ~pgm_sender_t ();
62 
63  int init (bool udp_encapsulation_, const char *network_);
64 
65  // i_engine interface implementation.
66  void plug (zmq::io_thread_t *io_thread_,
67  zmq::session_base_t *session_);
68  void terminate ();
69  void restart_input ();
70  void restart_output ();
71  void zap_msg_available () {}
72 
73  // i_poll_events interface implementation.
74  void in_event ();
75  void out_event ();
76  void timer_event (int token);
77 
78  private:
79 
80  // Unplug the engine from the session.
81  void unplug ();
82 
83  // TX and RX timeout timer ID's.
84  enum {tx_timer_id = 0xa0, rx_timer_id = 0xa1};
85 
86  // Timers are running.
87  bool has_tx_timer;
88  bool has_rx_timer;
89 
90  session_base_t *session;
91 
92  // Message encoder.
93  v1_encoder_t encoder;
94 
95  msg_t msg;
96 
97  // Keeps track of message boundaries.
98  bool more_flag;
99 
100  // PGM socket.
101  pgm_socket_t pgm_socket;
102 
103  // Socket options.
104  options_t options;
105 
106  // Poll handle associated with PGM socket.
107  handle_t handle;
108  handle_t uplink_handle;
109  handle_t rdata_notify_handle;
110  handle_t pending_notify_handle;
111 
112  // Output buffer from pgm_socket.
113  unsigned char *out_buffer;
114 
115  // Output buffer size.
116  size_t out_buffer_size;
117 
118  // Number of bytes in the buffer to be written to the socket.
119  // If zero, there are no data to be sent.
120  size_t write_size;
121 
122  pgm_sender_t (const pgm_sender_t&);
123  const pgm_sender_t &operator = (const pgm_sender_t&);
124  };
125 
126 }
127 #endif
128 
129 #endif
Definition: command.hpp:81
static char encoder[85+1]
Definition: zmq_utils.cpp:95
Definition: address.hpp:35