I am back with one more question:
I am trying to use this bit of code which is part of the HTTP_request_example_main.c code:
Code: Select all
struct timeval receiving_timeout;
receiving_timeout.tv_sec = 5;
receiving_timeout.tv_usec = 0;
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &receiving_timeout,
sizeof(receiving_timeout)) < 0) {
ESP_LOGE(TAG, "... failed to set socket receiving timeout");
close(s);
vTaskDelay(4000 / portTICK_PERIOD_MS);
continue;
}
ESP_LOGI(TAG, "... set socket receiving timeout success");
/* Read HTTP response */
do {
bzero(recv_buf, sizeof(recv_buf));
r = read(s, recv_buf, sizeof(recv_buf)-1);
for(int i = 0; i < r; i++) {
putchar(recv_buf[i]);
}
} while(r > 0);
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 276
ETag: W/"114-42fe4o8AhUSPVkQArHmDfvsQ0j4"
Date: Tue, 11 Sep 2018 14:00:45 GMT
Connection: keep-alive
JSON data....
For clarity I have omitted the printable text formatted IP and TCP headers and the actual JSON text data as it minified and therefore not easily readable. What is sure though is that all the headers and the JSON text are 100% OK.
What happens is that if I call the read function it will time out after 5 seconds, as set in the options, but it returns error -1 and sets the "errno" value to 11 ( EAGAIN ). I get none of the data that I know is sent back by the server via WireShark?
BTW: i have used ARC as a client application from another computer and there it works. The answer I see being sent by the server to the client using WireShark is properly received.
Is there anyone with an idea as to why the ESP32 software example would do that?
Still no solution found but a slight correction: once in a blue moon it does read the answer sent back from the server but usually it does not.