This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

netTCP_SendReady hangs when TCP established

Hi

I encounter a strange problem that the netTCP_SendReady gives false forever even the TCP connection is established. Is there a way to find out why the connection is not ready?

        while(is_sending_request)
        {
            switch (netTCP_GetState(socket))
            {
                case netTCP_StateUNUSED:
                case netTCP_StateCLOSED:
                    // Connect to TCP socket server
                    netTCP_Connect(socket, addr, 0);
                    break;

                case netTCP_StateESTABLISHED:

                    // Connected, send the data
                    if (netTCP_SendReady(socket) == true)
                    {
                        uint32_t mss = netTCP_GetMaxSegmentSize(socket);
                        send_len = (mss > needed_len) ? needed_len : mss;

                        uint8_t * sendbuf;
                        sendbuf = netTCP_GetBuffer(send_len);

                        strlcpy((char*) sendbuf, (char*) str, send_len);
                        netStatus status = netTCP_Send(socket, sendbuf, send_len - 1);
                        if(status != 0)
                        {
                            printf("TCP send error:%d\n",status);
                        }
                        chars_sent = ((int32_t) send_len) - 1;

                        is_sending_request = false;
                    }else
                    {
                        printf("waiting\n");
                    }

                    break;

                default:
                    break;
            }

  • Check your thread priorities. It looks like your thread has a higher priority than the network core thread. Thus, the network never gets a chance to update its state. This is a typical RTX thread deadlock. You can try adding osDelay(10) to the loop. This will trigger cooperative thread switching.