如何确保服务器在vc ++中的套接字编程中接收到客户端发送的所有数据 [英] how to ensure that the server received all the data sent by the client in socket programming in vc++

查看:88
本文介绍了如何确保服务器在vc ++中的套接字编程中接收到客户端发送的所有数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,

当数据从客户端发送到服务器时,服务器将如何确保已正确接收所有数据?即如何确保服务器已接收到客户端发送的所有数据.
谢谢
Dev



When data is sent from a client to a server ,how will the server make sure that it has received all the data accurately ? ie how to ensure that the server has received all the data sent by the client.
Thanks
Dev

推荐答案

这应由您的应用程序级通信协议定义. ( http://en.wikipedia.org/wiki/Application_layer [
—SA
This should be defined by your application-level communication protocol. (http://en.wikipedia.org/wiki/Application_layer[^].)

I would advise that the protocol should carry some redundancy and meta-data. The serialized data sent should better be "prefixed". For example, on the top of protocol, you are sending and receiving some variable number of data elements. Start it with sending the number of data elements receiving party should expect. Same thing goes for each data element and each part of it, hierarchically. When it comes to an individual string, first send the length of it (and probably some meta-data information like encoding of it). This way, each receiving party will maintain the integrity of each communication on every step.

—SA


这篇关于如何确保服务器在vc ++中的套接字编程中接收到客户端发送的所有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆