您好, 我有发送/接收文件大小的问题,特别是客户端的recv没有返回! 这是客户端代码的一部分:
uint32_t n_sizef=0;
//read size of file from s
nread=recv(s,&n_sizef,sizeof(n_sizef),0);
if(nread < 0){
printf("socket function read error");
break;
}
err_msg("(%s) -the file size is %" PRIu32,prog_name, n_sizef);
//convert format from net to host
h_sizef=ntohl(n_sizef);
printf("%s the file size is %" PRIu32,"\n",h_sizef);
这是服务器代码:
的一部分if (file = fopen(nomefile, "r")){
//get size file
uint32_t sizef;
uint32_t hsizefn;
fseek(file, 0, SEEK_END);
sizef=ftell(file);
err_msg("(%s) -the file size is %" PRIu32,prog_name, sizef,"bytes");
fclose(file);
//convert into net format
hsizefn=htonl(sizef);
err_msg("(%s) -the file size is %" PRIu32,prog_name, hsizefn);
write(sconn, &hsizefn, sizeof(hsizefn));
你可以帮帮我吗?谢谢