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 #if defined ZMQ_HAVE_OPENPGM 34 35 #include "stdint.hpp" 36 #include "io_object.hpp" 37 #include "i_engine.hpp" 38 #include "options.hpp" 39 #include "pgm_socket.hpp" 40 #include "v1_encoder.hpp" 41 #include "msg.hpp" 42 43 namespace zmq 44 { 45 class io_thread_t; 46 class session_base_t; 47 48 class pgm_sender_t ZMQ_FINAL : public io_object_t, public i_engine 49 { 50 public: 51 pgm_sender_t (zmq::io_thread_t *parent_, const options_t &options_); 52 ~pgm_sender_t (); 53 54 int init (bool udp_encapsulation_, const char *network_); 55 56 // i_engine interface implementation. has_handshake_stage()57 bool has_handshake_stage () { return false; }; 58 void plug (zmq::io_thread_t *io_thread_, zmq::session_base_t *session_); 59 void terminate (); 60 bool restart_input (); 61 void restart_output (); zap_msg_available()62 void zap_msg_available () {} 63 const endpoint_uri_pair_t &get_endpoint () const; 64 65 // i_poll_events interface implementation. 66 void in_event (); 67 void out_event (); 68 void timer_event (int token); 69 70 private: 71 // Unplug the engine from the session. 72 void unplug (); 73 74 // TX and RX timeout timer ID's. 75 enum 76 { 77 tx_timer_id = 0xa0, 78 rx_timer_id = 0xa1 79 }; 80 81 const endpoint_uri_pair_t _empty_endpoint; 82 83 // Timers are running. 84 bool has_tx_timer; 85 bool has_rx_timer; 86 87 session_base_t *session; 88 89 // Message encoder. 90 v1_encoder_t encoder; 91 92 msg_t msg; 93 94 // Keeps track of message boundaries. 95 bool more_flag; 96 97 // PGM socket. 98 pgm_socket_t pgm_socket; 99 100 // Socket options. 101 options_t options; 102 103 // Poll handle associated with PGM socket. 104 handle_t handle; 105 handle_t uplink_handle; 106 handle_t rdata_notify_handle; 107 handle_t pending_notify_handle; 108 109 // Output buffer from pgm_socket. 110 unsigned char *out_buffer; 111 112 // Output buffer size. 113 size_t out_buffer_size; 114 115 // Number of bytes in the buffer to be written to the socket. 116 // If zero, there are no data to be sent. 117 size_t write_size; 118 119 ZMQ_NON_COPYABLE_NOR_MOVABLE (pgm_sender_t) 120 }; 121 } 122 #endif 123 124 #endif 125