AnsweredAssumed Answered

RTCS TCP/IP

Question asked by 姚 玮 on Jul 12, 2015
Latest reply on Jul 22, 2015 by Carlos_Musich

Hi all,

I use K60 and MQX 4.1

I'd like to use socket receive TCP/IP packet every 100ms.

computer as server (device A)and k60 as client(device B).

Now K60 can receive data every 100ms .

My question is if device A disconnect and maybe 2mins later it reconnect, but the k60 can't receive data. I try to check the connection state if connection fail it will reconnect, but still not work.

 

  socket_init();

   uint16_t rlen=sizeof(raddr);

   i=connect(sock_list[0],(struct sockaddr *)&raddr,rlen);

   while(1)

   {

     k=RTCS_selectall(100);

     if (i!= RTCS_OK)

     {

       shutdown(sock_list[0],FLAG_ABORT_CONNECTION);

       socket_init();

       i=connect(sock_list[0],(struct sockaddr *)&raddr,rlen);

     }

     recv(sock_list[0],buffer_tcp,30,0);

}

Outcomes