mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/http_request_example_receiving_timeout' into 'master'
Added socket receiving timeout, ref. TW#14353 / GitHub issue #844 See merge request !1241
This commit is contained in:
commit
4bd12e10e7
@ -132,7 +132,7 @@ static void http_get_task(void *pvParameters)
|
|||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "... allocated socket\r\n");
|
ESP_LOGI(TAG, "... allocated socket");
|
||||||
|
|
||||||
if(connect(s, res->ai_addr, res->ai_addrlen) != 0) {
|
if(connect(s, res->ai_addr, res->ai_addrlen) != 0) {
|
||||||
ESP_LOGE(TAG, "... socket connect failed errno=%d", errno);
|
ESP_LOGE(TAG, "... socket connect failed errno=%d", errno);
|
||||||
@ -153,6 +153,18 @@ static void http_get_task(void *pvParameters)
|
|||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "... socket send success");
|
ESP_LOGI(TAG, "... socket send success");
|
||||||
|
|
||||||
|
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 */
|
/* Read HTTP response */
|
||||||
do {
|
do {
|
||||||
bzero(recv_buf, sizeof(recv_buf));
|
bzero(recv_buf, sizeof(recv_buf));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user