blob: 068028425357a7deef4496d0ec375db838e4b275 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/* -*- c++ -*- */
/*
* Copyright 2013,2014,2019 Free Software Foundation, Inc.
*
* This file is part of GNU Radio.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef INCLUDED_ZEROMQ_PULL_MSG_SOURCE_IMPL_H
#define INCLUDED_ZEROMQ_PULL_MSG_SOURCE_IMPL_H
#include "zmq_common_impl.h"
#include <gnuradio/zeromq/pull_msg_source.h>
namespace gr {
namespace zeromq {
class pull_msg_source_impl : public pull_msg_source
{
private:
int d_timeout; // microseconds, -1 is blocking
zmq::context_t d_context;
zmq::socket_t d_socket;
std::unique_ptr<boost::thread> d_thread;
const pmt::pmt_t d_port;
void readloop();
public:
bool d_finished;
pull_msg_source_impl(char* address, int timeout, bool bind);
~pull_msg_source_impl();
bool start() override;
bool stop() override;
std::string last_endpoint() override
{
char addr[256];
size_t addr_len = sizeof(addr);
d_socket.getsockopt(ZMQ_LAST_ENDPOINT, addr, &addr_len);
return std::string(addr, addr_len - 1);
}
};
} // namespace zeromq
} // namespace gr
#endif /* INCLUDED_ZEROMQ_PULL_MSG_SOURCE_IMPL_H */
|