[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Issue in TCP Socket with freeRTOS

From: Mohsin Madki
Subject: Re: [lwip-users] Issue in TCP Socket with freeRTOS
Date: Wed, 3 Jan 2018 10:01:42 +0530

You are creating a new task here 

 if(sys_thread_new("AcceptThread", New_Accept_Thread,
NULL, 512, 2) == NULL)
                                   LWIP_ASSERT("tcpecho(): New Accept Task

in the very next line you are closing connection here


the code does not guarantee that your connection will be alive by the time your created task (New_Accept_Thread) come to execution. 

Sol : why you want to create a task when the data is received instead you can create a function. that will solve your problem. 

Mohsin Madki. 

On Mon, Jan 1, 2018 at 3:10 PM, abdullah246 <address@hidden> wrote:
Hello, I am using FRDM-K64F and have changed the TCP echo+ freeRTOS according
to my need. I want a task that is always In a listening state. Whenever a
new client gets connected a new task should be created and some functions
should be added there. I am using the netconn api. I tried making the
struct netconn *conn, *newconn; global as I need the descriptor for
netconn_write in another task. But I get an error : netconn_write: invalid
conn . The code is as follows: -

#include "tcpecho.h"

#include "lwip/opt.h"


#include "lwip/sys.h"
#include "lwip/api.h"

int threadid = 0;
const struct netconn *conn, *newconn;
err_t err;

static void New_Accept_Thread(void *pvParameters)
                err_t err;
                char text[] = "Abdullah Shafiq";
                threadid ++;
                PRINTF("In New_Accept_Thread id = %d\r\n",threadid);

                while (1)

                                  err = netconn_write(newconn, text,
sizeof(text), NETCONN_COPY);

static void
tcpecho_thread(void *arg)
    struct netbuf *buf;
    void *data;
    u16_t len;

  conn = netconn_new(NETCONN_TCP);
  netconn_bind(conn, IP_ADDR_ANY, 5000);
#endif /* LWIP_IPV6 */
  LWIP_ERROR("tcpecho: invalid conn", (conn != NULL), return;);


  while (1)
                err = netconn_accept(conn, &newconn);
                if (err == ERR_OK)

                   if(sys_thread_new("AcceptThread", New_Accept_Thread,
NULL, 512, 2) == NULL)
                                   LWIP_ASSERT("tcpecho(): New Accept Task
creation failed.", 0);


                  } // if Accept Successfull
I tried commenting out netconn_close and netconn_delete but got no success

Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

lwip-users mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]