[zeromq-dev] How to open a socket on a real file ?
Pieter Hintjens
ph at imatix.com
Tue Jun 4 17:08:54 CEST 2013
Hi Laurent,
What Ian is showing is the ability of zmq_poll to work with native
file handles as well as ZeroMQ sockets. There's an explanation in the
zmq_poll man page. http://api.zeromq.org/3-2:zmq-poll
However what you're asking for is somewhat different and I'd suggest
reading Chapter 7 of the Guide (or buy the O'Reilly book!) which
develops a file transfer protocol and application (FileMQ).
Finally, you may simply use FileMQ in your application, it is a C API
that is very easy to call. https://github.com/zeromq/filemq
-Pieter
On Tue, Jun 4, 2013 at 12:18 PM, Laurent Alebarde <l.alebarde at free.fr> wrote:
> Hi list,
>
> In the presentation of Ian Barber, there is a PHP example where the socket
> is a file descriptor on the standard input.
>
> $ctx = new ZMQContext();
> $sock = $ctx->getSocket(ZMQ::SOCKET_PULL);
> $sock->bind("tcp://*:5555");
> $fh = fopen("php://stdin", 'r');
> $poll = new ZMQPoll();
> $poll->add($sock, ZMQ::POLL_IN);
> $poll->add($fh, ZMQ::POLL_IN);
> while(true) {
> $events = $poll->poll($read, $write);
> if($read[0] === $sock) {
> echo "ZMQ: ", $read[0]->recv();
> } else {
> echo "STDIN: ", fgets($read[0]);
> }}
>
> I have not find anything on that in the documentation. I would need more
> information please, especially to transfer a file from one process to an
> other, possibly with streaming, in C.
>
> Cheers,
>
> Laurent.
>
>
>
>
> _______________________________________________
> 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