fly135 wrote:I stared at this for a while and can't figure out the logic....
"len = send(connect_socket, recvbuf + (count - to_write), to_write, 0);"
Assuming the recvbuf is actually the sendbuf, and assuming you are in some loop sending "to_write" number of bytes each time, I can't understand how "recvbuf + (count - to_write)" is computing the pointer of the buffer to send.
John A
Code: Select all
count = strlen(recvbuf); //recvbuf //test_pic
to_write = strlen(recvbuf);
g_total_data = 0;
while (count > 0) {
len = send(connect_socket, recvbuf + (to_write - count), EXAMPLE_DEFAULT_PKTSIZE, 0x18); //recvbuf ->test_pic //0x10: more; 0x08:do not block
if(len == -1) {
//ESP_LOGI(TAG, "transmit error .error_cnt:%d", error_cnt);
//vTaskDelay(10 / portTICK_RATE_MS);
error_cnt++;
if(error_cnt > 2000)
break;
else
continue;
}
//send(connect_socket, recvbuf + (to_write - count), EXAMPLE_DEFAULT_PKTSIZE, 0);
if (len > 0) {
g_total_data += len;
count -= len;
//ESP_LOGI(TAG, "len %d, count :%d \r\n" , len, count);
}else {
int err = get_socket_error_code(connect_socket);
ESP_LOGI(TAG, "line 190 err = %d", err);
#if EXAMPLE_ESP_TCP_PERF_TX && EXAMPLE_ESP_TCP_DELAY_INFO
g_send_fail++;
#endif
ESP_LOGI(TAG, "len %d \r\n" , len);
if (err != ENOMEM) {
show_socket_error_reason("send_data", connect_socket);
ESP_LOGI(TAG, "error = %d ..\r\n",show_socket_error_reason("send_data", connect_socket));
break;
}
}
}
If the send flag is 0, return of send is 1460(size of 1 packet)
If the send flag is 0x18, return of send is -1 sometimes.