1 /*
2 Copyright (c) 2007-2011 iMatix Corporation
3 Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
4
5 This file is part of 0MQ.
6
7 0MQ is free software; you can redistribute it and/or modify it under
8 the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 0MQ is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "../include/zmq.h"
22
23 #include "push.hpp"
24 #include "err.hpp"
25 #include "pipe.hpp"
26
push_t(class ctx_t * parent_,uint32_t tid_)27 zmq::push_t::push_t (class ctx_t *parent_, uint32_t tid_) :
28 socket_base_t (parent_, tid_),
29 lb (this)
30 {
31 options.type = ZMQ_PUSH;
32 options.requires_in = false;
33 options.requires_out = true;
34 }
35
~push_t()36 zmq::push_t::~push_t ()
37 {
38 }
39
xattach_pipes(class reader_t * inpipe_,class writer_t * outpipe_,const blob_t & peer_identity_)40 void zmq::push_t::xattach_pipes (class reader_t *inpipe_,
41 class writer_t *outpipe_, const blob_t &peer_identity_)
42 {
43 zmq_assert (!inpipe_ && outpipe_);
44 lb.attach (outpipe_);
45 }
46
process_term(int linger_)47 void zmq::push_t::process_term (int linger_)
48 {
49 lb.terminate ();
50 socket_base_t::process_term (linger_);
51 }
52
xsend(zmq_msg_t * msg_,int flags_)53 int zmq::push_t::xsend (zmq_msg_t *msg_, int flags_)
54 {
55 return lb.send (msg_, flags_);
56 }
57
xhas_out()58 bool zmq::push_t::xhas_out ()
59 {
60 return lb.has_out ();
61 }
62
63