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.

TCP Socket API

Other Parts Discussed in Thread: CC3200

I am using TCP socket API . Packets are sending & receiving correctly.I am sending these Packets  on UART. But when other device which is connected to the CC3200 using TCP is close then CC3200 send continuously packets on UART. what is that problem?  

  • Hi Sumit,

    Can you please clarify your question and share more details on the setup?

    Regards,
    Ankur
  • In my project I need to receive packets from mobile app & this packets I given to the another MCU using UART. I create socket & wait fot connect to the other device. After connecting to the device it sends some packets but if mobile app close his socket or he disconnected then CC3200 continuously send previous data to the MCU.

    // creating a TCP socket
    iSockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);


    / binding the TCP socket to the TCP server address
    iStatus = sl_Bind(iSockID, (SlSockAddr_t *)&sLocalAddr, iAddrSize);

    // putting the socket for listening to the incoming TCP connection
    iStatus = sl_Listen(iSockID, 0);

    // setting socket option to make the socket as non blocking
    iStatus = sl_SetSockOpt(iSockID, SL_SOL_SOCKET, SL_SO_NONBLOCKING,
    &lNonBlocking, sizeof(lNonBlocking));

    // accepts a connection form a TCP client, if there is any
    // otherwise returns SL_EAGAIN
    iNewSockID = sl_Accept(iSockID, ( struct SlSockAddr_t *)&sAddr,
    (SlSocklen_t*)&iAddrSize);

    iStatus = sl_Recv(iNewSockID, g_cBsdBuf, iTestBufLen, 0);

    this is my code. any other clarification you need then let me know.

    Thanks
  • Sumit,

    Thanks for the details.
    Are you checking for the return value of 'sl_Recv()' to detect disconnection? When the remote client disconnects the 'sl_Recv()' will return 0.

    Regards,
    Ankur
  • Thanks for your response it works. But I have another issue if mobile app disconnect from socket then it reconnected to my device then mobile app shown connected to the cc3200 device After that if mobile send some data to cc3200 but sl_recv function return 0.

    I use sl_Select function to know whether any data on arrivie on socket. Then I use sl_recv function
  • Sumit,

    Once the client socket gets disconnected you need to close the socket on the CC3200 application and accept the new connection.
    Can you please share the logic/step by step process on CC3200 side?

    Regards,
    Ankur
  • Hi Sumit,

    I am closing this thread, if the issue still exists please open a new thread and add a link to this one for reference.

    Regards,
    Ankur