On Tue, Mar 17, 2015 at 7:15 PM, Sayan Goswami <[email protected]> wrote:
> Hi All, > > I am using CodedOutputStream and CodedInputStream to transfer messages > across a network like so: > > *Client requests:* > > Socket serverSocket = new Socket(hosts, ports); > > CodedOutputStream outputStream = CodedOutputStream.newInstance( > serverSocket.getOutputStream()); > > outputStream.flush(); > > CodedInputStream inputStream = CodedInputStream.newInstance(serverSocket > .getInputStream()); > > > // the following happens inside a loop > > Request request = Request.newBuilder() > > .setType(Request.RequestType.GET) > > .setKey(key) > > .build(); > > > outputStream.writeRawVarint32(request.getSerializedSize()); > > request.writeTo(outputStream); > > outputStream.flush(); > > > *Server Processes Request:* > > > CodedOutputStream output = CodedOutputStream.newInstance(clientSocket > .getOutputStream()); > > output.flush(); > > CodedInputStream input = CodedInputStream.newInstance(clientSocket > .getInputStream()); > > > int length = input.readRawVarint32(); > > byte[] message = input.readRawBytes(length); > > Request request = Request.parseFrom(message); > > // do things with request > > > Now, each request of mine, has a serialized size of 56.. so I can send > many messages up the stream, but what can I do when the size limit of 64MB > is exceeded? Is there any way to reset the buffer? Following is the error > message I am getting: > > > Protocol message was too large. May be malicious. Use > CodedInputStream.setSizeLimit() to increase the size limit. > > > CodedInputStream.resetSizeCounter() should do the trick. You can call it before reading each message. > Thanks, > > > Sayan > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
