Receiving data from client on the server end failed

瘦欲@ 提交于 2019-12-12 03:53:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!