<p>First ensure, that is 28332 port used: -zmqpubhashtx=tcp://127.0.0.1:28332 bitcoind parameter, next call python zmq_sub.py. This should work</p>

CC BY-SA 3.0
2017-01-09T16:46:53.903Z
2017-01-09T16:46:53.903Z
Saku
<p>I call:</p>
<p>bitcoind -zmqpubrawtx=ipc:///tmp/bitcoind.tx.raw</p>
<p>or even call:</p>
<p>bitcoind -zmqpubhashtx=tcp://127.0.0.1:9050 -
zmqpubrawtx=ipc:///tmp/bitcoind.tx.raw</p>
<p>where 9050 is port from bicoin config.
File /tmp/bitcoind.tx.raw is empty i has lenght=0
How can I dump transactions?
I read, this file is websocket and I must subscribe to it:</p>
<pre><code>Client side, then, the ZeroMQ subscriber socket must have the ZMQ_SUBSCRIBE 
option set to one or either of these prefixes (for instance, just hash); 
without doing so will result in no messages arriving. Please see 
contrib/zmq/zmq_sub.py for a working example.&quot;
</code></pre>
<p>How can I read it programically?
I try create c++ program from Python sources and <a href="https://github.com/plq/zmq.git" rel="nofollow noreferrer">https://github.com/plq/zmq.git</a></p>
<h1>include </h1>
<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;
#include &lt;cstring&gt;

#include &quot;zmq.hpp&quot;

using std::cout;
using std::endl;

void recv_multipart(zmq::socket_t &amp;socket) {
    int64_t more=-1;
    size_t more_size = sizeof (more);
    while(more) {
        zmq::message_t response;
        socket.recv(&amp;response);

        std::string response_str((const char *)response.data(),
                                                             response.size());
        cout &lt;&lt; response_str &lt;&lt; endl;

        socket.getsockopt(ZMQ_RCVMORE, &amp;more, &amp;more_size);
    }
}


int main(int argc, char **argv) {
    zmq::context_t context(1);
    zmq::socket_t socket(context, ZMQ_SUB);
    socket.setsockopt(ZMQ_SUBSCRIBE, &quot;hashblock&quot;);
    socket.setsockopt(ZMQ_SUBSCRIBE, &quot;hashtx&quot;);
    socket.setsockopt(ZMQ_SUBSCRIBE, &quot;rawblock&quot;);
    socket.setsockopt(ZMQ_SUBSCRIBE, &quot;rawtx&quot;);
    //socket.connect(/*argv[2]*/&quot;ipc:///tmp/bitcoind.tx.raw&quot;);
    socket.connect(&quot;tcp://127.0.0.1:28332&quot;);

    size_t arg_len= std::strlen(&quot;Unknown&quot;);
    zmq::message_t message(arg_len);
    std::memcpy(message.data(), &quot;Unknown&quot;, arg_len);
    socket.send(message);        
    recv_multipart(socket);        
    return 0;
}
</code></pre>

CC BY-SA 3.0
2017-01-09T12:58:05.227Z
Can I use https://github.com/zaphoyd/websocketpp ?
Saku
CC BY-SA 3.0
2017-01-09T13:19:08.347Z
It is a ZMQ socket. It is not a Websocket. Socket here refers to the old UNIX concept of a bidirectional interprocess pipe represented. ZMQ is a particular network protocol for publishing/subscribing to events.
Pieter Wuille
CC BY-SA 3.0
2017-01-09T13:32:14.793Z
soc=socket(PF_INET, SOCK_STREAM, 0); ? , sai.sin_family=PF_INET;
sai.sin_port=port; ?//how subscribe and read it? I need source code
Saku
CC BY-SA 3.0
2017-01-09T14:02:38.350Z
You need libzmq.
Pieter Wuille
CC BY-SA 3.0
2017-01-09T14:18:28.587Z
I have compiled https://github.com/plq/zmq and this say: zmq <SOCKET_TYPE> <URI> <MSG>; how is SOCKET_TYPE,URI and MSG for this case?
Saku
CC BY-SA 3.0
2017-01-09T14:30:06.767Z
zmq REQ ipc:///tmp/bitcoind.tx.raw ZMQ_SUBSCRIBE nor
zmq REQ tcp://127.0.0.1:28332 ZMQ_SUBSCRIBE nothing gets
Saku
CC BY-SA 3.0
2017-01-09T14:51:22.047Z
That shell wrapper does not support SUBSCRIBE sockets.
Pieter Wuille
CC BY-SA 3.0
2017-01-09T16:19:30.817Z
I used Bitcoin Python example: sudo apt-get install python-zmq / 
python zmq_sub.py; but in this case program waits and no message to console
Saku
<zeromq>
bitcoind -zmqpubhashtx causes empty raw file
Saku
# bitcoind -zmqpubhashtx causes empty raw file

(Asked by: username_0 on 2017-01-09)

I call:
bitcoind -zmqpubrawtx=ipc:///tmp/bitcoind.tx.raw
or even call:
bitcoind -zmqpubhashtx=tcp://127.0.0.1:9050 -
zmqpubrawtx=ipc:///tmp/bitcoind.tx.raw
where 9050 is port from bicoin config.
File /tmp/bitcoind.tx.raw is empty i has lenght=0
How can I dump transactions?
I read, this file is websocket and I must subscribe to it:
Client side, then, the ZeroMQ subscriber socket must have the ZMQ_SUBSCRIBE 
option set to one or either of these prefixes (for instance, just hash); 
without doing so will result in no messages arriving. Please see 
contrib/zmq/zmq_sub.py for a working example."

How can I read it programically?
I try create c++ program from Python sources and https://github.com/plq/zmq.git
include 
#include 
#include 
#include 

#include "zmq.hpp"

using std::cout;
using std::endl;

void recv_multipart(zmq::socket_t &socket) {
    int64_t more=-1;
    size_t more_size = sizeof (more);
    while(more) {
        zmq::message_t response;
        socket.recv(&response);

        std::string response_str((const char *)response.data(),
                                                             response.size());
        cout << response_str << endl;

        socket.getsockopt(ZMQ_RCVMORE, &more, &more_size);
    }
}


int main(int argc, char **argv) {
    zmq::context_t context(1);
    zmq::socket_t socket(context, ZMQ_SUB);
    socket.setsockopt(ZMQ_SUBSCRIBE, "hashblock");
    socket.setsockopt(ZMQ_SUBSCRIBE, "hashtx");
    socket.setsockopt(ZMQ_SUBSCRIBE, "rawblock");
    socket.setsockopt(ZMQ_SUBSCRIBE, "rawtx");
    //socket.connect(/*argv[2]*/"ipc:///tmp/bitcoind.tx.raw");
    socket.connect("tcp://127.0.0.1:28332");

    size_t arg_len= std::strlen("Unknown");
    zmq::message_t message(arg_len);
    std::memcpy(message.data(), "Unknown", arg_len);
    socket.send(message);        
    recv_multipart(socket);        
    return 0;
}

**Tags:** zeromq

> **Comments:**
> **username_0**: Can I use https://github.com/zaphoyd/websocketpp ?  
> **username_1**: It is a ZMQ socket. It is not a Websocket. Socket here refers to the old UNIX concept of a bidirectional interprocess pipe represented. ZMQ is a particular network protocol for publishing/subscribing to events.  
> **username_0**: soc=socket(PF_INET, SOCK_STREAM, 0); ? , sai.sin_family=PF_INET; sai.sin_port=port; ?//how subscribe and read it? I need source code  
> **username_1**: You need libzmq.  
> **username_0**: I have compiled https://github.com/plq/zmq and this say: zmq <SOCKET_TYPE> <URI> <MSG>; how is SOCKET_TYPE,URI and MSG for this case?  
> **username_0**: zmq REQ ipc:///tmp/bitcoind.tx.raw ZMQ_SUBSCRIBE nor zmq REQ tcp://127.0.0.1:28332 ZMQ_SUBSCRIBE nothing gets  
> **username_1**: That shell wrapper does not support SUBSCRIBE sockets.  
> **username_0**: I used Bitcoin Python example: sudo apt-get install python-zmq /  python zmq_sub.py; but in this case program waits and no message to console  

---

## 1 answers

### Answer by username_0 on 2017-01-09. Score: 1

First ensure, that is 28332 port used: -zmqpubhashtx=tcp://127.0.0.1:28332 bitcoind parameter, next call python zmq\_sub.py. This should work


---

