慕侠2389804
杰瑞的回答很棒。但是,它不处理大的响应。处理此问题的简单更改:memset(response, 0, sizeof(response));total = sizeof(response)-1;received = 0;do {
printf("RESPONSE: %s\n", response);
// HANDLE RESPONSE CHUCK HERE BY, FOR EXAMPLE, SAVING TO A FILE.
memset(response, 0, sizeof(response));
bytes = recv(sockfd, response, 1024, 0);
if (bytes < 0)
printf("ERROR reading response from socket");
if (bytes == 0)
break;
received+=bytes;} while (1);