Skip to content

Better signature to send string from ROUTER to DEALER #209

Description

@AntiTenzor

I heavily use ROUTER <--> DEALER communication and I see a very common pattern like this:
`
// Somewhere at the beginning of a program execution
ZSocket clrZmqRouter = new ZSocket(clrZmqContext, ZSocketType.ROUTER);

// Many minutes later IN ANOTHER THREAD
lock (clrZmqRouter)
{
string added = "serialized message with a command";
if (clrZmqRouter.SendFrameMore(new ZFrame(dealerIdentity), ZSocketFlags.More | ZSocketFlags.DontWait, out error) &&
clrZmqRouter.SendFrame(new ZFrame(added), ZSocketFlags.DontWait, out error))
{
// All good. We are happy.
}
else
{
// Log an error.
}
}
`

q1) Is it the best and CORRECT way to make NON-BLOCKING send to the dealer?

q2) Is it possible to implement special method in ZSocket for this operation?
Something like this:
bool ZSocket.SendToDealer(string dealerIdentity, string message, ZSocketFlags flags = ZSocketFlags.DontWait, out ZError error)

q3) Is it possible to make a special class ZRouter : object that will contain ZSocket as its private field ?
And provide only some special methods to simplify ROUTER <--> DEALER communication?

Also I would like to make this ZRouter class absolutely thread safe for external callers.
Is it possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions