Line data Source code
1 :
2 : #ifndef __ZMQ_UDP_ENGINE_HPP_INCLUDED__
3 : #define __ZMQ_UDP_ENGINE_HPP_INCLUDED__
4 :
5 : #include "io_object.hpp"
6 : #include "i_engine.hpp"
7 : #include "address.hpp"
8 : #include "udp_address.hpp"
9 :
10 : #define MAX_UDP_MSG 8192
11 :
12 : namespace zmq
13 : {
14 : class io_thread_t;
15 : class session_base_t;
16 :
17 : class udp_engine_t : public io_object_t, public i_engine
18 : {
19 : public:
20 : udp_engine_t ();
21 : ~udp_engine_t ();
22 :
23 : int init (address_t *address_, bool send_, bool recv_);
24 :
25 : // i_engine interface implementation.
26 : // Plug the engine to the session.
27 : void plug (zmq::io_thread_t *io_thread_, class session_base_t *session_);
28 :
29 : // Terminate and deallocate the engine. Note that 'detached'
30 : // events are not fired on termination.
31 : void terminate ();
32 :
33 : // This method is called by the session to signalise that more
34 : // messages can be written to the pipe.
35 : void restart_input ();
36 :
37 : // This method is called by the session to signalise that there
38 : // are messages to send available.
39 : void restart_output ();
40 :
41 0 : void zap_msg_available () {};
42 :
43 : void in_event ();
44 : void out_event ();
45 :
46 : private:
47 :
48 : bool plugged;
49 :
50 : fd_t fd;
51 : session_base_t* session;
52 : handle_t handle;
53 : address_t *address;
54 :
55 : unsigned char out_buffer[MAX_UDP_MSG];
56 : unsigned char in_buffer[MAX_UDP_MSG];
57 : bool send_enabled;
58 : bool recv_enabled;
59 : };
60 : }
61 :
62 : #endif
|