如何“确定”?消息看起来像?
我有一个向服务器发送数据的设备。
Data
[ Client ] == > [ Server ]
在服务器上验证后,我想返回一条消息:
OK
[ Client ] < == [ Server ]
是否有标准的“OK”消息要返回?还有“错误”消息?看起来怎么样? (例如“:0011”,“:110F”)
I have a device that sends data to a server.
Data
[ Client ] == > [ Server ]
After the validation on the server I want to return a message:
OK
[ Client ] < == [ Server ]
Is there a standard "OK" message to return? And an "ERROR" message? How does it looks like? (e.g. ":0011", ":110F")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须设计一个应用程序级协议。 TCP 是字节流,因此即使客户端->服务器部分中“数据”的定义也需要某种协议,以便接收方可以知道数据由哪些字节组成(何时停止读取)。
几种常见的协议类型是...
我相信您可以提出其他想法,但这是基本工作:在 TCP 字节流之上定义应用程序级协议。
You've got to design an application-level protocol. TCP is a byte stream, so even the definition of "Data" in your client->server piece needs some protocol so that the receiver can know what bytes make up the data (when to stop reading).
A couple of common types of protocols are...
I'm sure you could come up with other ideas, but that's the basic job: defining your application-level protocol on top of TCP's byte stream.