libzmq master
The Intelligent Transport Layer

pgm_sender.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2009-2011 250bpm s.r.o.
00003     Copyright (c) 2007-2009 iMatix Corporation
00004     Copyright (c) 2010-2011 Miru Limited
00005     Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
00006 
00007     This file is part of 0MQ.
00008 
00009     0MQ is free software; you can redistribute it and/or modify it under
00010     the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation; either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     0MQ is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 
00023 #ifndef __ZMQ_PGM_SENDER_HPP_INCLUDED__
00024 #define __ZMQ_PGM_SENDER_HPP_INCLUDED__
00025 
00026 #include "platform.hpp"
00027 
00028 #if defined ZMQ_HAVE_OPENPGM
00029 
00030 #ifdef ZMQ_HAVE_WINDOWS
00031 #include "windows.hpp"
00032 #endif
00033 
00034 #include "stdint.hpp"
00035 #include "io_object.hpp"
00036 #include "i_engine.hpp"
00037 #include "options.hpp"
00038 #include "pgm_socket.hpp"
00039 #include "encoder.hpp"
00040 
00041 namespace zmq
00042 {
00043 
00044     class pgm_sender_t : public io_object_t, public i_engine
00045     {
00046 
00047     public:
00048 
00049         pgm_sender_t (class io_thread_t *parent_, const options_t &options_);
00050         ~pgm_sender_t ();
00051 
00052         int init (bool udp_encapsulation_, const char *network_);
00053 
00054         //  i_engine interface implementation.
00055         void plug (class io_thread_t *io_thread_,
00056             class session_base_t *session_);
00057         void unplug ();
00058         void terminate ();
00059         void activate_in ();
00060         void activate_out ();
00061 
00062         //  i_poll_events interface implementation.
00063         void in_event ();
00064         void out_event ();
00065         void timer_event (int token);
00066 
00067     private:
00068 
00069         //  TX and RX timeout timer ID's.
00070         enum {tx_timer_id = 0xa0, rx_timer_id = 0xa1};
00071 
00072         //  Timers are running.
00073         bool has_tx_timer;
00074         bool has_rx_timer;
00075 
00076         //  Message encoder.
00077         encoder_t encoder;
00078 
00079         //  PGM socket.
00080         pgm_socket_t pgm_socket;
00081 
00082         //  Socket options.
00083         options_t options;
00084 
00085         //  Poll handle associated with PGM socket.
00086         handle_t handle;
00087         handle_t uplink_handle;
00088         handle_t rdata_notify_handle;
00089         handle_t pending_notify_handle;
00090 
00091         //  Output buffer from pgm_socket.
00092         unsigned char *out_buffer;
00093         
00094         //  Output buffer size.
00095         size_t out_buffer_size;
00096 
00097         //  Number of bytes in the buffer to be written to the socket.
00098         //  If zero, there are no data to be sent.
00099         size_t write_size;
00100 
00101         pgm_sender_t (const pgm_sender_t&);
00102         const pgm_sender_t &operator = (const pgm_sender_t&);
00103     };
00104 
00105 }
00106 #endif
00107 
00108 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines