[Top][All Lists]

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

[lwip-users] Issue in TCP Socket with freeRTOS

From: Abdullah Shafiq
Subject: [lwip-users] Issue in TCP Socket with freeRTOS
Date: Mon, 1 Jan 2018 08:25:38 +0000

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"


#define Multiple_Threads          0



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

reply via email to

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