thanks,

yes it was the null character, on the server side when copying buffer
into string, i had add 1 to the
size of the buffer (i guess for the null), then the parsing was ok
with no error.



On Wed, Nov 10, 2010 at 1:42 PM, Evan Jones <ev...@mit.edu> wrote:
> Brad Lira wrote:
>>
>> address_book.SerializeToString(&mystr)
>> strncpy(buf, mystr.c_str(), strlen(mystr.c_str()));
>
> strlen will return a shorter length than the real length, due to null
> characters. Use mystr.size()
>
>
>
>> Maybe this method is not the right way to send string across socket.
>> I tried using SerializeToFileDescriptor(socket), that worked on the
>> client side, but on the server side, i never get the message with UDP
>> sockets.
>> is there a better way of sending data across network?
>
> You probably want to use TCP sockets, since it provides retransmissions for
> you. Also, you'll need to prepend a length. See:
>
> http://code.google.com/apis/protocolbuffers/docs/techniques.html#streaming
>
>
> Or search the group archives for threads such as:
>
> http://groups.google.com/group/protobuf/browse_thread/thread/3af587ab16132a3f
>
>
> Good luck,
>
> Evan
>
> --
> Evan Jones
> http://evanjones.ca/
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to proto...@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