xreq.cpp 1.67 KB
Newer Older
1
/*
2
    Copyright (c) 2007-2010 iMatix Corporation
3 4 5 6

    This file is part of 0MQ.

    0MQ is free software; you can redistribute it and/or modify it under
7
    the terms of the GNU Lesser General Public License as published by
8 9 10 11 12 13
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    0MQ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU Lesser General Public License for more details.
15

16
    You should have received a copy of the GNU Lesser General Public License
17 18 19
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

20
#include "../include/zmq.h"
21 22 23 24

#include "xreq.hpp"
#include "err.hpp"

Martin Sustrik's avatar
Martin Sustrik committed
25 26
zmq::xreq_t::xreq_t (class ctx_t *parent_, uint32_t tid_) :
    socket_base_t (parent_, tid_),
27 28
    fq (this),
    lb (this)
29
{
30
    options.type = ZMQ_XREQ;
31 32 33 34 35 36 37 38 39
    options.requires_in = true;
    options.requires_out = true;
}

zmq::xreq_t::~xreq_t ()
{
}

void zmq::xreq_t::xattach_pipes (class reader_t *inpipe_,
40
    class writer_t *outpipe_, const blob_t &peer_identity_)
41
{
42 43 44
    zmq_assert (inpipe_ && outpipe_);
    fq.attach (inpipe_);
    lb.attach (outpipe_);
45 46
}

47
void zmq::xreq_t::process_term (int linger_)
48
{
49 50
    fq.terminate ();
    lb.terminate ();
51
    socket_base_t::process_term (linger_);
52 53 54 55
}

int zmq::xreq_t::xsend (zmq_msg_t *msg_, int flags_)
{
56
    return lb.send (msg_, flags_);
57 58 59 60
}

int zmq::xreq_t::xrecv (zmq_msg_t *msg_, int flags_)
{
61
    return fq.recv (msg_, flags_);
62 63 64 65
}

bool zmq::xreq_t::xhas_in ()
{
66
    return fq.has_in ();
67 68 69 70
}

bool zmq::xreq_t::xhas_out ()
{
71
    return lb.has_out ();
72 73
}