Hi @Devaharsha ,
So sorry for my later reply.
Talk about your issues.
You already can receive the data, and just can't receive it complete, it means your socket already works, I think it is related to the time, you mentioned task is 1ms delay, I think it is not enough, please use long time, eg, 1s, then test it again.
In the previous time, I have even test the socket to receive a lot of data, it also works, you can check my post:
https://community.nxp.com/t5/i-MX-RT-Knowledge-Base/The-RT-speech-recognition-system-based-on-VIT-to...
The related function is:
static void
weather_thread(void *arg)
{
int sock = -1,rece;
struct sockaddr_in client_addr;
char* host_ip;
ip4_addr_t dns_ip;
err_t err;
uint32_t *pSDRAM= pvPortMalloc(BUF_LEN);//
//==============
//DNS resolving have issues
#if 0
if (ipaddr_aton(HOST_NAME, &dns_ip) && IP_IS_V4(&dns_ip))
{
/* Already an IP address */
err = ERR_OK;
}
else
{
/* Resolve MQTT broker's host name to an IP address */
PRINTF("Resolving \"%s\"...\r\n", HOST_NAME);
err = netconn_gethostbyname(HOST_NAME, &dns_ip);
}
PRINTF("host name : %s , host_ip : %s\r\n",HOST_NAME,host_ip);
#endif
//===================
#ifdef LWIP_DNS
ip4_addr_t dns_ip;
netconn_gethostbyname(HOST_NAME, &dns_ip);
host_ip = ip_ntoa(&dns_ip); //DSN get IP
// host_ip = IP_ADDR;
PRINTF("host name : %s , host_ip : %s\r\n",HOST_NAME,host_ip);
#else
host_ip = HOST_NAME;
PRINTF("host name : %s , host_ip : %s\r\n",HOST_NAME,host_ip);
#endif
while(1)
{
//add the command request, only cmd == weather flag, then call it.
if((weather_data.ww_flag == 1))
{
if(weather_data.vc_index >= 3)
{
// create connection
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
PRINTF("Socket error\n");
vTaskDelay(10);
continue;
}
client_addr.sin_family = AF_INET;
client_addr.sin_port = htons(PORT);
client_addr.sin_addr.s_addr = inet_addr(host_ip);
memset(&(client_addr.sin_zero), 0, sizeof(client_addr.sin_zero));
if (connect(sock, (struct sockaddr *)&client_addr, sizeof(struct sockaddr)) == -1)
{
PRINTF("Connect failed!\n");
closesocket(sock);
vTaskDelay(10);
continue;
}
PRINTF("Connect to server successful!\r\n");
// PRINTF("\r\n************************************************************\n\r");
// PRINTF("\r\n Begin write\n\r");
write(sock,get_weather,sizeof(get_weather));
while (1)
{
//receive data
rece = recv(sock, (uint8_t*)pSDRAM, BUF_LEN, 0);//BUF_LEN
if (rece <= 0)
break;
// PRINTF("%s\n",(uint8_t*)pSDRAM);
memcpy(weather_data.weather_info, pSDRAM,1500);//max 1457
// PRINTF("---rece=%d\n",rece);
// PRINTF("\r\n*******************receive data*******************************\n\r");
}
// PRINTF("\r\n***************************end*******************************\n\r");
//weather process
Weather_process();
memset(pSDRAM,0,BUF_LEN);
closesocket(sock);
}
//clean data
memset(weather_data.weather_info, 0, sizeof(weather_data.weather_info));
weather_data.ww_flag = 0;
weather_data.vc_index = 0;
}
vTaskDelay(10000);//about 10s //10000
}
}
You can see, I even use 10s, as my data is large.
I also test the RT1170 socket on my side, but seems recently, our IT limit the ENET cable, so my office PC even connection have issues, but I am sure my code is the correct one, as I have tested previously when the PC have no enet limit.
So, you can refer to my above code, use long delay, and try it again.
Wish it helps you!
Best Regards,
Kerry