Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 客户机-服务器通信中的校验和代码_C_Client Server_Checksum - Fatal编程技术网

C 客户机-服务器通信中的校验和代码

C 客户机-服务器通信中的校验和代码,c,client-server,checksum,C,Client Server,Checksum,我已经编写了一个代码来发送TCP数据包和接收确认数据包 我想在代码中实现校验和以检查数据一致性,但未能编写用于检查数据一致性的代码(用C语言) 请给我代码。通常的方法是使用其中一个,例如crc32 在源代码的顶部添加 #include <zlib.h> 然后根据需要多次添加数据,通常是在某些循环上下文中 my_crc = crc32(my_crc, (unsigned char *)some_buffer_pointer, length_of_buffer); 记住要链接到zli

我已经编写了一个代码来发送TCP数据包和接收确认数据包

我想在代码中实现校验和以检查数据一致性,但未能编写用于检查数据一致性的代码(用C语言)


请给我代码。

通常的方法是使用其中一个,例如
crc32

在源代码的顶部添加

#include <zlib.h>
然后根据需要多次添加数据,通常是在某些循环上下文中

my_crc = crc32(my_crc, (unsigned char *)some_buffer_pointer, length_of_buffer);
记住要链接到zlib库

-lz
如果您不想使用库函数,例如,因为您在MPU上,那么您可以使用

如果您的平台上没有zlib,您可以从下载


如果您在Windows上,希望其他人会建议您使用什么。

查看IDE的所有菜单,找到菜单项,上面写着“给我代码”,然后选择它。
-lz