[zeromq-dev] Question about zero-copying, local and remote clients

Luca Boccassi luca.boccassi at gmail.com
Wed Sep 14 01:25:12 CEST 2016


If you ask for TCP, you are going to get TCP.

But you can however bind the same socket to multiple endpoints, one
IPC, one TCP, etc.

Note that "true" zero copy happens with ZMQ_PAIR sockets over
inproc:// transport. IPC uses unix file sockets, so there is at least
a write syscall and thus a copy.

On 13 September 2016 at 20:37, Mateusz Jemielity
<m.jemielity at is-wireless.com> wrote:
> Hi,
>
>
>
> I have a question about 0MQ’s internal use of zero-copy.
>
>
>
> Suppose that I have a client-server setup using req/rep sockets that are
> sending large messages between themselves. There are multiple clients, some
> may run on the same host as the server, others are on remote hosts. All
> endpoints use tcp, so I’d have:
>
> Server: zmq_bind(server_socket, “tcp://*:5000”);
>
> Client 1 (on same host): zmq_connect(client1_socket,
>tcp://127.0.0.1:5000”);
>
> Client 2 (on remote host): zmq_connect(client2_socket,
>tcp://192.168.1.2:5000”);
>
>
>
> Does 0MQ somehow know that server and client 1 are on the same machine? If
> it knew, then it could, for example, use shared memory to transfer the
> messages, without actually using tcp stack.
>
> I guess I could explicitly use ipc transport for processes on same host and
> do another bind in the server, but can I do it in such kinda-generic,
> single-bind way?
>
>
>
> If 0MQ doesn’t do this internally, can I get requester’s endpoint string in
> the server? Or at least some indication of endpoint being local or remote?
> If I had the endpoint, then I could parse it for “127.0.0.1” or “localhost”,
> etc. and then set up a scheme for sending some shared memory parameters
> instead of a giant message.
>
>
>
> Finally, whetever’s the answer for req/rep, does it apply for pub/sub, etc?
>
>
>
> Regards,
>
> Mateusz
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list