gpt4 book ai didi

c# - 通过 TCP C# 接收结构

转载 作者:行者123 更新时间:2023-11-30 17:58:50 24 4
gpt4 key购买 nike

这篇文章与我之前发表的一篇文章直接相关

Sending C structs through TCP in C#

我的下一个问题是从设备接收适当的响应。该文档为我提供了返回结构的以下代码。

typedef struct{
/*This value represents if the API request to modify has been a success or not*/
return_t ret_val;

/*Error code indicating error details*/
error_t err_code;

/*Response object for GET type action*/
U8 payload[0];
}MsgResp;

我的问题是,如何将通过 TCP 接收到的原始字节流放入此结构中?同样,我的直觉告诉我与 memcpy 有关,但我不知道这如何转换为 C#。

我也对 return_t 和 error_t 类型感到困惑,因此对这些类型的任何深入了解也会有所帮助。

最佳答案

上面 SLAks 评论中的链接正是我所需要的。

链接在这里:How To Convert Structure to byte array in C#

关于c# - 通过 TCP C# 接收结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11955404/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com