There is another problem.

If I use FileOutputStream, the message would not be flush whether
Flush() is be used or not.
It would be flush until the file descriptor is closed.

It is still the EOF's problem?
if yes, it looks not suitable for socket programing.

I have seem the same problem on SerializeToFileDescriptor.

Thanks

> On 5月20日, 下午11時19分, Jason Hsueh <jas...@google.com> wrote:
> Haven't used stringbuf before, but it looks like that just sets the internal
> buffer for the stringbuf. You are going through a few layers of buffering
> here; you probably want to just directly use a ZeroCopyOutputStream
> implementation that writes to the socket, like FileOutputStream, which
> allows you to control the buffer size. Then just have GzipOutputStream wap
> that instead of an OstreamOutputStream.
>
>
>
>
>
>
>
> On Fri, May 20, 2011 at 3:29 AM, Shin <for.shin1...@gmail.com> wrote:
> > I attempt to use compressed data for my socket programing.
> > The problem is the fixed output buffer size.
>
> > Message *request;
> > char buf[512];
> > stringbuf sbuf;
> > sbuf.pubsetbuf((char*)buf, sizeof(buf));
> > ostream os(&sbuf);
> > OstreamOutputStream *oos = new OstreamOutputStream(&os);
> > GzipOutputStream *gzout = new GzipOutputStream(oos);
> > request->SerializeToZeroCopyStream(gzout);
>
> > write(sd, buf, sizeof(buf));
>
> > I wanna use a loop to send the data.
> > But I don't know how to control the stream to output fixed-size data.
>
> > Thanks.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Protocol Buffers" group.
> > To post to this group, send email to protobuf@googlegroups.com.
> > To unsubscribe from this group, send email to
> > protobuf+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/protobuf?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to