Brad Lira wrote:
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:

Or search the group archives for threads such as:

Good luck,


Evan Jones

You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to