I've got a java server and a c++ client, client sends a message to the
server.

In a first moment we had the message structure made by simple format
like strings or integers, and the message sending/receiving with
serialization and deserialization were working perfectly.

Nowadays we added a "enum" in the structure and now on the java side,
the deserialization doesn't work anymore:

c++ client sending:

bool Client::SendMsg(const char* pStr)
{
        if (send(m_iSock, (char *) pStr, strlen(pStr), 0) == -1)        //
send(id_socket,stringa,lunghezza stringa,flags)
        {
                perror("Client::SendString, send");
                return false;
        }
return true
}

//on the client'smain
ss=(const char*)malloc(1000);
ss = obj.c_str();
mylink.SendMsg(ss);

java server receiving:

 public int ReceiveMsg() throws IOException
  {

        InputStream InMsg = sock.getInputStream();
        ProtoMessage Msg = ProtoMessage.parseFrom(InMsg);  //THIS
THROWS THE ERROR
        sock.close;
}


the error is:
Exception in thread "main"
com.google.protobuf.InvalidProtocolBufferException: While parsing a
protocol message, the input ended unexpectedly in the middle of a
field.  This could mean either than the input has been truncated or
that an embedded message misreported its own length.
        at
com.google.protobuf.InvalidProtocolBufferException.truncatedMessage(InvalidProtocolBufferException.java:
49)
        at
com.google.protobuf.CodedInputStream.refillBuffer(CodedInputStream.java:
711)
        at
com.google.protobuf.CodedInputStream.readRawByte(CodedInputStream.java:
734)
        at
com.google.protobuf.CodedInputStream.readRawVarint32(CodedInputStream.java:
338)
        at
com.google.protobuf.CodedInputStream.readInt32(CodedInputStream.java:
198)


On the other side otherwise c++ client can deserialize the stream
perfectly.
I'm gettin mad, without the enum the send/receive is working!
any ideas?
thanks in advance
Enrico

-- 
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