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:
You received this message because you are subscribed to the Google Groups "Protocol
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at