Skip to content

Commit 03dfbd8

Browse files
committed
updates
1 parent c932588 commit 03dfbd8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

helper.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ bool handle_get_version(int client_fd, char* client_str) {
1414
return true;
1515
}
1616

17+
void respond_buff_to_client(int fd, char* buff, int buff_len) {
18+
int len_htonl = htonl(buff_len);
19+
int err = send(fd, &len_htonl, sizeof(len_htonl), 0);
20+
if (err < 0) {
21+
perror("send len in respond_buff_to_client");
22+
}
23+
err = send(fd, buff, buff_len, 0);
24+
if (err < 0) {
25+
perror("send buff in respond_buff_to_client");
26+
}
27+
}
28+
1729
void respond_str_to_client(int fd, char* str) {
1830
int len_htonl = htonl(strlen(str));
1931

@@ -76,7 +88,7 @@ int get_int_from_client(int client_fd) {
7688
bool get_buffer_from_client(int client_fd, char* output, int output_size) {
7789
int client_send_len;
7890
int bytes_read = recv(client_fd, &client_send_len, sizeof(client_send_len), 0);
79-
91+
8092
if (bytes_read == -1) {
8193
perror("recv from get_str_from_client in len");
8294
}

0 commit comments

Comments
 (0)