[zeromq-dev] Does ZMQ_STREAM sockets buffer the whole request?

Sébastien Pierre sebastien.pierre at gmail.com
Wed Sep 4 21:06:59 CEST 2013


Done https://github.com/zeromq/libzmq/pull/647


2013/9/4 Pieter Hintjens <ph at imatix.com>

> Hi Sébastien,
>
> You're right that the man page could be improved. Why not do that, and
> send us a pull request?
>
> -Pieter
>
> On Wed, Sep 4, 2013 at 8:10 PM, Sébastien Pierre
> <sebastien.pierre at gmail.com> wrote:
> > Thanks Pieter,
> >
> > On a side note, the documentation might benefit from an example and
> maybe a
> > clarification. I found this part from doc/zmq_socket.txt a bit
> misleading:
> >
> > "To close a specific client connection, as a server, send a zero-length
> > message following the identity frame."
> >
> > which I translated to the following code:
> >
> > zmq_send (server, 0, 0, ZMQ_SNDMORE);
> > zmq_send (server, id, id_size, ZMQ_SNDMORE);
> >
> > I obviously read "followed by" instead of "following", but maybe saying
> > "send the identify frame followed by a zero-length message" would be
> > clearer.
> >
> > I also got surprised that not using the ZMQ_SNDMORE in zmq_send flag
> would
> > result in not being able to respond to further requests.
> >
> > Thanks again for your explanation,
> >
> > -- Sébastien
> >
> >
> >
> >
> > 2013/9/4 Pieter Hintjens <ph at imatix.com>
> >>
> >> ZMQ_STREAM does buffer, but only between the I/O thread and the
> >> application. That is, if you're reading from the socket slower than
> >> the network delivers data, it will queue up. However since it's a
> >> stream, potentially infinite, it would be pathological (and difficult)
> >> to buffer the whole request (essentially the whole connection).
> >>
> >> Remember that with TCP streams, there are no messages. When parsing
> >> HTTP, you read and accumulate data until you get either an end of
> >> connection, or that famous blank line signalling the end of the
> >> header; you then have to look for a Content-Size header, parse that,
> >> and then you can expect that many bytes of data after the blank line.
> >>
> >> -Pieter
> >>
> >> On Wed, Sep 4, 2013 at 7:41 PM, Sébastien Pierre
> >> <sebastien.pierre at gmail.com> wrote:
> >> > Hi all,
> >> >
> >> > I'm new to ZMQ and wrote a quick and dirty HTTP server using the
> >> > recently
> >> > released ZMQ_STREAM socket type. I was wondering (before spending too
> >> > much
> >> > time on it) if this type of socket buffers the client's request before
> >> > sending it to the server (in the zmq_rcv).
> >> >
> >> > I'm thinking of the particular use case where a web browser is
> uploading
> >> > a
> >> > large file (say a 100Mb video). I've read here and there in the ZMQ
> >> > guide
> >> > that messages have to fit in the whole memory... is this the case with
> >> > ZMQ_STREAM as well? I assume that it's not the case and that we would
> >> > receive a series of messages instead of a 100Mb+ message, but I just
> >> > wanted
> >> > to hear that from the horse's mouth ;)
> >> >
> >> > Thanks,
> >> >
> >> > -- Sébastien
> >> >
> >> > _______________________________________________
> >> > zeromq-dev mailing list
> >> > zeromq-dev at lists.zeromq.org
> >> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >> >
> >> _______________________________________________
> >> zeromq-dev mailing list
> >> zeromq-dev at lists.zeromq.org
> >> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> >
> >
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20130904/913f669b/attachment.htm>


More information about the zeromq-dev mailing list