diff options
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -174,16 +174,20 @@ int main(int argc, char *argv[]) } else if (reply_type == 6) { // we are getting STATIONINFO // get the string size - uint8_t string_size = -1; - if (recv(sockfd, &string_size, 1, 0) == -1) { - perror("recv in stationinfo"); + uint32_t buf_string_size = -1; + int bytes_to_read = sizeof(uint32_t); + if (recv_all(sockfd, &buf_string_size, &bytes_to_read) == -1) { + perror("recv_all 1 in stationinfo"); exit(1); } + + uint32_t string_size = ntohl(buf_string_size); + printf("string size: %d\n", string_size); char *info = malloc(string_size); if(info == NULL) { perror("malloc in info"); } - int bytes_to_read = string_size; + bytes_to_read = string_size; if (recv_all(sockfd, info, &bytes_to_read) == -1) { - perror("recv_all in station info"); + perror("recv_all 2 in stationinfo"); exit(1); } remove_timeout(sockfd); |