This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS3137: TCP Client Reconnection fail

Part Number: TMS570LS3137

Tool/software:

I am having a minimal setup with the Client code running on my TMS570 MCU and server code on another laptop.

I am using LwIP 1.4.1 library, and the client fails to reconnect if the server is disconnected. 

err_t
TCASTCPClientInit(uint32_t ip_addr, uint32_t _port)
{

struct ip_addr ipaddr;
void *pcb;

ipaddr.addr = ip_addr;
//IP4_ADDR(&ipaddr, 192, 168, 1, 10);

pcb = tcp_new();
gTCPCpcb = pcb;
tcp_err(pcb, TCPCError);

terrCode = tcp_connect(pcb, &ipaddr, _port, TCPCConnected);
return(terrCode);

This is the logic for initialization. I am expecting a non-zero error value if the client is not connected to the server(server script not running).

But the error code always returns 0 even in case of successful connection or no connection. 

How can this be sorted? 

  • Hi Chandana,

    As highlighted in below image, the return value of the function "tcp_connect" doesn't indicating connection status.

    The OK (i.e. 0 value) in the return status just indicating that "connect request has been sent", and the non-zero value indicating that "failed to send the connection request" due to invalid arguments etc.

    And also, as mentioned if the connection was successful, it will call the argument that is passing with "tcp_connected_fn connected".

    --
    Thanks & regards,
    Jagadish.

  • Thank you Jagadish !

    Regards,

    Chandana.