问题
I have asked several questions about protocol buffers about socket transferring...again,I got a problem when I want to receive data at the server end from the client.
here is the client end code:
int sendSystem(int sockfd, const void *buf, size_t nbytes, int flags) {
return ::send(sockfd, buf, nbytes, flags);
}
it's like the client do send data by integers standing for each byte.so the data was transferring in bytes.
here is the server end code:
GameRequest gameRequest=GameRequest.parseFrom(CodedInputStream.newInstance(socket.getInputStream()));
GameRequest gameRequest=GameRequest.parseDelimitedFrom(socket.getInputStream());
GameRequest gameRequest=GameRequest.parseFrom(socket.getInputStream());
I have tried each ways above to receive data and parse it...turns out none is a good way..mostly I just got a message as "the message has an invalid tag" or if I turn on the debug mode,it just stand by at the line of the code above and I can't move to next step or move into the calling method cuz the button step over and step into was disabled...
来源:https://stackoverflow.com/questions/14354591/receiving-data-from-client-on-the-server-end-failed