attempt to wait for newline
previously, if a line was split between TCP packets it would be truncated
This commit is contained in:
parent
0893d2dd3a
commit
7a8de94092
13
fbflut.c
13
fbflut.c
|
@ -29,7 +29,18 @@ void *handle_connection(void *socket_desc) {
|
|||
|
||||
while ((read_size = recv(sock, client_message, 36, MSG_PEEK)) > 0) {
|
||||
client_message[read_size] = '\0';
|
||||
read_to = (char *)strchrnul(client_message, '\n')-client_message;
|
||||
read_to = strchr(client_message, '\n');
|
||||
if (read_to == 0) {
|
||||
if (read_size == 36) {
|
||||
read_to = client_message+read_size;
|
||||
} else {
|
||||
memset(client_message, 0, 36);
|
||||
read_size = recv(sock, client_message, 36, MSG_PEEK | MSG_WAITALL);
|
||||
client_message[read_size] = '\0';
|
||||
read_to = strchrnul(client_message, '\n');
|
||||
}
|
||||
}
|
||||
read_to = (char *)read_to-client_message;
|
||||
memset(client_message, 0, 36);
|
||||
read_size = recv(sock, client_message, read_to+1, 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user