zmsg | small program for sending messages via zcash encrypted memo | Runtime Evironment library
kandi X-RAY | zmsg Summary
kandi X-RAY | zmsg Summary
zmsg uses the encrypted memo field of zcash sheilded transactions to send messages to other parties. The sent messages get stored in the zcash blockchain and the recipient can check for messages at any time (no need to be online at the same time). Since the messages get stored in the blockchain, they are on every full zcash node. The implication here is that its not possible to tell who the target of any given message is. Currently, each message sends 0.0001 ZEC. You can change this value by setting the --txval flag on sendmsg.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- getReceivedForAddr gets all received messages for a given address
- SendMessage sends a message to the remote address
- readAuthCreds reads username and password from environment variables .
- WaitForOperation waits for the given operation to be completed .
- CheckMessages returns all messages that are received
- getTransaction returns information about a transaction .
- main is the main entry point
- checkOperationStatus returns the status of the given op .
- getMyAddresses returns a list of all connected addresses
- init the default client
zmsg Key Features
zmsg Examples and Code Snippets
Community Discussions
Trending Discussions on zmsg
QUESTION
I have a serial device that is being converted to TCP/IP through a serial server. This seems to work correctly as other applications can connect this way.
In my application, I'm trying to use ZeroMQ ZMQ_STREAM to send a request for information to the device, and wait for a reply.
...ANSWER
Answered 2018-Aug-03 at 22:02Using ZMQ_STREAM is a little tricky, but you should be able to use a single socket to communicate with an external TCP socket.
One disclaimer, I'll show examples using zmqpp library, but key point is not exact functions to call but rather how to correctly apply flow, so I hope you will be able to transform it to pure ZeroMQ.
Take a look at zmq api docs, Native pattern paragraph.
To initiate the connection with remote, after connect you need to obtain ZMQ_IDENTITY.
To open a connection to a server, use the zmq_connect call, and then fetch the socket identity using the ZMQ_IDENTITY zmq_getsockopt call.
QUESTION
I am facing a memory leakage issue while using czmq library for a simple PUB / SUB
application. So, here is the description:
The setup contains multiple publishers and multiple subscribers. Each publisher and subscriber is a separate thread. Threads are normal POSIX threads on a Linux machine. I am sending messages from the publisher to subscriber using zmsg_send
and zframe
. Each message containing one frame each. I am able to send and receive messages, but over time I am seeing memory occupied by the application increases. I am using tcp pub-sub sockets.
One thing I would like to mention is that after sending the message I am not destroying it as it is mentioned in the documentation that it will.destroy them after sending successfully. While receiving the message I copy the received message into a local structure and then I destroy the frame and zmsg. I am using zpoller to wait on the socket for messages. It's running on an arm processor. Could anyone please guide me towards, what things I need to keep in mind to avoid the memory leakage? The Application sends messages at the rate of 10 Hz.
And clue on the general mistakes that I might be making will be helpful. Thanks.
...ANSWER
Answered 2018-Jun-07 at 20:24You need to dig further to work out what is leaking the memory.
Run your application under valgrind
, once you are at the point you think the memory is being leaked, break the execution and valgrind
should report all possible leaks. Hopefully the real leak should stand out as it will be large and obvious.
Other things to try would be reducing the HWM
's to 1 for all sockets and see if that makes a difference. It could be that the memory leak is just ZeroMQ using the buffers (set by HWM
). Linux will not always return the memory to the heap if its freed unless it is needed elsewhere.
Finally thanks to ZeroMQ's architecture you could very easily split your application into two, then your PUB
and SUB
would be separate and narrow down the leak further.
QUESTION
I want to know if there's a way for a ZeroMQ socket to do only reading or only writing. Because, it seems to me that, even though there are async/multithreading examples, every thread still uses recv-then-send loop. The problem I have is, I want to have receiveMessage()
that reads from ZeroMQ socket and sendMessage(msg)
that writes to ZeroMQ socket. But each of those methods would run in separate thread that is constructed IN ANOTHER class. Here's my code (I'm using jeromq from Scala):
ANSWER
Answered 2018-Mar-17 at 00:07Yes, several ways.
a ) use a tandem of simplex archetypes: PUSH/PULL
writes and PULL/PUSH
reads
b ) use a tandem of simplex archetypes: (X)PUB/(X)SUB
writes and (X)SUB/(X)PUB
reads
.recv()
-then-.send()
loop.
Well, this observation is related more to the actual socket-archetype, some of which indeed require a mandatory two-step ( hardwired inside their internal FSA-s ) sequencing of .recv()
--.send()
--...
Well, here the challenge starts: ZeroMQ was since its initiation designed as principally zero-sharing so as to foster performance and independence. Zen-of-Zero is interesting design principle in distributed-system design.
Yet, recent re-design efforts have presented in API 4.2+ a will to achieve ZeroMQ socket Access-points to become thread-safe ( which goes against the initial principle of share-nothing ), so if going to experiment in this direction, your may arrive in territories, that work, but at a cost of decline from Zen-of-Zero.
ZeroMQ Socket Access-point(s) should never be shared, even if possible, because of design purity.
Better equip such class with another pair of simplex PUSH/PULL
-s, if you strive for separation of OOP-concerns, but your head-end(s) of such read-only-specialised + write-only-specialised sockets will have to handle the cases, when a "remote" ( beyond the foreign class-boundary of abstraction ) ZeroMQ Socket-archetype FSA and it's settings and performance tweaking and error-state(s) and the "remote" class will have to arrange all such plus mediate all message-transfers to/from the native ZeroMQ-socket ( which is principally isolated and hidden for both of the head-end ( specialised ) classes ).
In any case, doable with due design care.
ZeroMQ resources are not any cheaply composable / disposable trashAn idea of:
QUESTION
A client sends a structure ( containing an array ) to a server ten times. Servers job is to receive this structure and to print it. But it receives the structure only once and prints it and exits giving this error
"terminate called after throwing an instance of 'zmq::error_t'
".
This is the client C++ code:
...ANSWER
Answered 2018-Feb-11 at 16:36as the original REP/REQ enforces a strict chain of .send()-.recv()-.send()-.recv()- ...
If your needs are exactly as expressed above, a just a change of the ZeroMQ Scalable Formal Communication Archetype pattern is enough.
If you opt to keep as close as possible to the REQ/REP
"similarity", use XREQ/XREP
, if having more to say and planning for some further extending the distributed signalling/messaging services infrastructure, better use a tandem of single-direction hoses C->S
+ S->C
using a pair of PUSH/PULL
+ PUSH/PULL
.
A PAIR/PAIR
might be an option if a messaging paradigm can live with just one, exclusive, pair of nodes, where PAIR/PAIR
( as implemented ) does not provide a way to later expand to .connect()
into N:1
or 1:M
or N:M
peer-nodes framework.
QUESTION
I have bunch of keys and values that I want to send to our messaging queue by packing them in one byte array. I will make one byte array of all the keys and values which should always be less than 50K and then send to our messaging queue.
Packet class:
...ANSWER
Answered 2018-Jan-11 at 08:24I don't see the definition of sender
in Packet
. I assume it is defined as a private instance variable?
The design indeed needs to be fixed.
By having the Packet
class do the sending, the design violates the Single responsibility principle. There should be a separate (possibly abstract) class that prepares the data to be sent (prepares a java.nio.Buffer
instance) and it can have one or more sub classes, one of which returns a java.nio.ByteBuffer
instance.
A separate class that gets a Buffer
and performs the sending. This (possibly abstract) class can have sub classes for the different sending platforms and methods.
then, you need another class that implements the Builder pattern. Clients that wish to send packets, use the builder to specify concrete Packet
and Sender
(and possibly other needed properties, like a socket number) and then call send()
that does the sending.
QUESTION
I am using below class to send data to our messaging queue by using socket either in a synchronous way or asynchronous way as shown below.
sendAsync
- It sends data asynchronously without any timeout. After sending(on LINE A)
it adds toretryHolder
bucket so that if acknowledgement is not received then it will retry again from the background thread which is started in a constructor.send
- It internally callssendAsync
method and then sleep for a particular timeout period and if acknowledgement is not received then it removes fromretryHolder
bucket so that we don't retry again.
So the only difference between those two above methods is - For async I need to retry at all cost but for sync I don't need to retry but looks like it might be getting retried since we share the same retry bucket cache and retry thread runs every 1 second.
ResponsePoller
is a class which receives the acknowledgement for the data that was sent to our messaging queue and then calls removeFromretryHolder
method below to remove the address so that we don't retry after receiving the acknowledgement.
ANSWER
Answered 2017-Dec-20 at 12:37The code has a number of potential issues:
- An answer may be received before the call to
retryHolder#put
. - Possibly there is a race condition when messages are retried too.
- If two messages are sent to the same address the second overwrites the first?
- Send always wastes time with a sleep, use a
wait
+notify
instead.
I would store a class with more state instead. It could contain a flag (retryIfNoAnswer
yes/no) that the retry handler could check. It could provide waitForAnswer
/markAnswerReceived
methods using wait
/notify
so that send doesn't have to sleep for a fixed time. The waitForAnswer
method can return true if an answer was obtained and false on timeout. Put the object in the retry handler before sending and use a timestamp so that only messages older than a certain age are retried. That fixes the first race condition.
EDIT: updated example code below, compiles with your code, not tested:
QUESTION
I have a java program that using ZeroMQ.
But I found the program blocked in context.term();
if receiving a message( recvMsg() )
time out!
ANSWER
Answered 2017-Sep-04 at 05:31According to the API, http://api.zeromq.org/4-2:zmq-term, it will block when there's still messages to transmit. This suggests that you other machine or process, the one that will open the REP socket; isn't running.
QUESTION
I am trying to implement client server using ZeroMQ.
I am running a server in an infinite loop, bound to a socket and polling the the socket infinitely.
When a client sends a request, the server receives only for the first time. The subsequent requests are not received by the server, below is my code snippet
Server :
...ANSWER
Answered 2017-Jan-28 at 19:08A REP
socket must send a reply before it can receive again.
If you're just wanting a 1 way communication you might be better using a PUB
& SUB
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install zmsg
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page