I'm using the winsock api to send and receive protocol messages
between a client program and a server program. One program sends out a
periodic status message received by the second program, while the
second program sends a command message and then receives whatever was
sent to it. The problem isn't with the sending and receiving process,
but with decoding the protocol buffer message. When the command
message is sent, it appears to send and encode correctly, but when the
message is received by the other program, it's supposed to print out
the message contents, but just prints garbage. I'll put code similar
to mine here so that it makes more sense. I had to change the names
though, so hopefully it still makes sense.
This is a snippet so you can see the general idea:

Sending program:
MyMessageNamespace::MyMessage msg;
char caBuffer[64];
MyMessageNamespace::MyMessage::commandmsg * cmd=
int length = msg.ByteSize();
if (msg.SerializeToArray(caSbuf,sizeof(caSbuf)))

Receiving program:
MyMessageNamespace::MyMessage msg;
//other things, some of which involve system event code having to do
with socket messages.
//finished with other things
if (WaitForSingleObject(Mymessageinfo->hmutex, 500) == WAIT_OBJECT_0)
    msg.ParseFromArray(Mymessageinfo->mutexmessage, Mymessageinfo-
    //other things happen here

Any ideas or does this not even make any sense? In case you're
wondering, yes we are basically using two different protocols here,
which I'm sure isn't helping the problem.
In any case, when I throw in code breaks, it looks like the problem
occurs when receiving program tries to decode the message. It could be
the message itself, but I think it has to do with the fact that I'm
new to protocol buffers and don't entirely understand all the things I
could be doing wrong here. But any help would be much appreciated!

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 
For more options, visit this group at 

Reply via email to