[zeromq-dev] Can we create client socket in server scope before send ack to client?

Tomasz Michalski tmichalski23 at gmail.com
Thu Oct 10 09:45:51 CEST 2019


Hi
I have three machines. On each of them there is daemon app which perform
role as server REP and bind to  "tcp://*:5555". Moreover on each machine
one-shoot tool can be started by user in runtime which behaves as client -
create socket on port 5555,
connect("tcp://concreteIpAddressGivenByUserOnArgList::5555"), send msg,
destroy socket and exit.

Here is the most complex case which come to my mind. Will it work?

server on machine A:
{
    mSock.bind("tcp://*:5555");
    mSock.recv(msg)

    //(Machine B sends to machine A msg)
    based on header I start concrete handler, in particular it may be
handler which send msg2 to machine C
    {
        //Machine A in server process scope sends to machine C msg2
        //create temporary client sock2:
        sock2.connect("tcp://anotherMachineIpAddr:5555");
        sock2.send(msg2);
        sock2.recv(msg2Ack); (*) -> please see below on machine C use case
        //destroy sock2
    }

    //Send resp to machine A
    mSock.send(msgAck)
}

Machine C:
server App: gets msg2 from machine A, process it
in the meantime someone starts tool which connect to machine A and send msg3
server App: ack for msg2 is sent to machine A

The question is what message will be received at machine A server at this
point (*). Will it be msg3 or ack for msg2?

Another more complex case, what will happen if machine C will be machine
B?! Will here occur deadlock?

Thanks in advance for response
BR
Tomek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20191010/db3677f9/attachment.htm>


More information about the zeromq-dev mailing list