Skip to content

Commit 27109be

Browse files
committed
Revert "Correct test socket_sigio"
This reverts commit b812918.
1 parent b812918 commit 27109be

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

TESTS/netsocket/socket_sigio/main.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,16 @@ bool find_substring(const char *first, const char *last, const char *s_first, co
6767
void get_data(TCPSocket* sock){
6868
bool result = false;
6969
// Server will respond with HTTP GET's success code
70-
int len = 0;
71-
int ret;
72-
while((ret = sock->recv(buffer+len, sizeof(buffer) - 1 - len)) > 0) {
73-
len += ret;
74-
}
75-
buffer[len] = '\0';
70+
const int ret = sock->recv(buffer, sizeof(buffer) - 1);
71+
if(ret <= 0)
72+
return;
73+
74+
buffer[ret] = '\0';
7675

7776
// Find 200 OK HTTP status in reply
78-
bool found_200_ok = find_substring(buffer, buffer + len, HTTP_OK_STR, HTTP_OK_STR + strlen(HTTP_OK_STR));
77+
bool found_200_ok = find_substring(buffer, buffer + ret, HTTP_OK_STR, HTTP_OK_STR + strlen(HTTP_OK_STR));
7978
// Find "Hello World!" string in reply
80-
bool found_hello = find_substring(buffer, buffer + len, HTTP_HELLO_STR, HTTP_HELLO_STR + strlen(HTTP_HELLO_STR));
79+
bool found_hello = find_substring(buffer, buffer + ret, HTTP_HELLO_STR, HTTP_HELLO_STR + strlen(HTTP_HELLO_STR));
8180

8281
TEST_ASSERT_TRUE(found_200_ok);
8382
TEST_ASSERT_TRUE(found_hello);
@@ -86,7 +85,7 @@ void get_data(TCPSocket* sock){
8685

8786
TEST_ASSERT_EQUAL(result, true);
8887

89-
printf("HTTP: Received %d chars from server\r\n", len);
88+
printf("HTTP: Received %d chars from server\r\n", ret);
9089
printf("HTTP: Received 200 OK status ... %s\r\n", found_200_ok ? "[OK]" : "[FAIL]");
9190
printf("HTTP: Received '%s' status ... %s\r\n", HTTP_HELLO_STR, found_hello ? "[OK]" : "[FAIL]");
9291
printf("HTTP: Received message:\r\n");

0 commit comments

Comments
 (0)