c - 使用c语言在服务器套接字中连续读取字符串
问题描述
x_hex=(char*)malloc(sizeof(char)*65);
bzero(x_hex,65);
check= read(newsockfd,x_hex,65);
if ( check < 0)
error("ERROR reading from socket");
printf("Bytes recieved: %d\n", check);
printf("x_hex is %s\n",x_hex);
BN_hex2bn(&x, x_hex);
free(x_hex);
//second read
y_hex=(char*)malloc(sizeof(char)*65);
bzero(y_hex,65);
check= read(newsockfd,y_hex,65);
if ( check < 0)
error("ERROR reading from socket");
printf("Bytes recieved: %d\n", check);
printf("y_hex %s\n", y_hex);
BN_hex2bn(&y, y_hex);
free(y_hex);
输出-->
//x的输出应该是64,但是这里我只得到了1?
Bytes recieved: 1
comit1_x_hex from EV driver is
Bytes recieved: 64
comit1_y_hex from EV driver is
f0c8ff0cb9872942bc604523cb15243eafe12dc1bdd20339258f2d4eb0bcf1b9
解决方案
推荐阅读
- linux - Bash 时差计算
- html - 如何摆脱 HTML 中正文列之间的边距间隙(使用 css 模板但自己编辑了很多)
- firebase - 什么是 firebase / firestore 时区
- java - 如何将 URL 图像传递给另一个活动 Android 工作室
- ruby - 我该如何解决这个错误?网络::ReadTimeout (网络::ReadTimeout)
- asp.net-web-api2 - 启用 Cors 后 PUT 和 EDIT 出现 404(未找到)
- ssl - 此证书缺少“主机”字段。这使得它不适合网站
- maven-dependency - Maven - ojdbc14.jar 依赖问题
- javascript - Javascript document.ready 在循环中重复(无 DRY)
- java - 以毫秒为单位存储android时间戳值,而不会在字符串变量中丢失其精度