client.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #include "precompiled.hpp"
4 #include "macros.hpp"
5 #include "client.hpp"
6 #include "err.hpp"
7 #include "msg.hpp"
8 
9 zmq::client_t::client_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
10  socket_base_t (parent_, tid_, sid_, true)
11 {
12  options.type = ZMQ_CLIENT;
13  options.can_send_hello_msg = true;
14  options.can_recv_hiccup_msg = true;
15 }
16 
17 zmq::client_t::~client_t ()
18 {
19 }
20 
21 void zmq::client_t::xattach_pipe (pipe_t *pipe_,
22  bool subscribe_to_all_,
23  bool locally_initiated_)
24 {
25  LIBZMQ_UNUSED (subscribe_to_all_);
26  LIBZMQ_UNUSED (locally_initiated_);
27 
28  zmq_assert (pipe_);
29 
30  _fq.attach (pipe_);
31  _lb.attach (pipe_);
32 }
33 
34 int zmq::client_t::xsend (msg_t *msg_)
35 {
36  // CLIENT sockets do not allow multipart data (ZMQ_SNDMORE)
37  if (msg_->flags () & msg_t::more) {
38  errno = EINVAL;
39  return -1;
40  }
41  return _lb.sendpipe (msg_, NULL);
42 }
43 
44 int zmq::client_t::xrecv (msg_t *msg_)
45 {
46  int rc = _fq.recvpipe (msg_, NULL);
47 
48  // Drop any messages with more flag
49  while (rc == 0 && msg_->flags () & msg_t::more) {
50  // drop all frames of the current multi-frame message
51  rc = _fq.recvpipe (msg_, NULL);
52 
53  while (rc == 0 && msg_->flags () & msg_t::more)
54  rc = _fq.recvpipe (msg_, NULL);
55 
56  // get the new message
57  if (rc == 0)
58  rc = _fq.recvpipe (msg_, NULL);
59  }
60 
61  return rc;
62 }
63 
64 bool zmq::client_t::xhas_in ()
65 {
66  return _fq.has_in ();
67 }
68 
69 bool zmq::client_t::xhas_out ()
70 {
71  return _lb.has_out ();
72 }
73 
74 void zmq::client_t::xread_activated (pipe_t *pipe_)
75 {
76  _fq.activated (pipe_);
77 }
78 
79 void zmq::client_t::xwrite_activated (pipe_t *pipe_)
80 {
81  _lb.activated (pipe_);
82 }
83 
84 void zmq::client_t::xpipe_terminated (pipe_t *pipe_)
85 {
86  _fq.pipe_terminated (pipe_);
87  _lb.pipe_terminated (pipe_);
88 }
client.hpp
NULL
NULL
Definition: test_security_zap.cpp:405
options
Message * options
Definition: src/google/protobuf/descriptor.cc:3119
EINVAL
#define EINVAL
Definition: errno.hpp:25
ZMQ_CLIENT
#define ZMQ_CLIENT
Definition: zmq_draft.h:15
precompiled.hpp
zmq_assert
#define zmq_assert(x)
Definition: err.hpp:102
errno
int errno
macros.hpp
LIBZMQ_UNUSED
#define LIBZMQ_UNUSED(object)
Definition: macros.hpp:6
msg.hpp
err.hpp
true
#define true
Definition: cJSON.c:65


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:48