aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/client.c b/client.c
index 4ab7457..7b9e036 100644
--- a/client.c
+++ b/client.c
@@ -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);