diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-09-24 04:17:57 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-09-24 04:17:57 -0400 |
commit | 0e34f9ce017d0a9afc2b2354854a0e76019a86ec (patch) | |
tree | 284ad75e920e70798109f46545a3783e78396442 /client.c | |
parent | 28d4aacf00d6b7389dd2440060541a623ec25f1d (diff) |
fix for stations with lots of stations
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); |