|
From: | Mohsin Madki |
Subject: | Re: [lwip-users] Issue in TCP Socket with freeRTOS |
Date: | Wed, 3 Jan 2018 10:01:42 +0530 |
in the very next line you are closing connection hereif(sys_thread_new("AcceptThread", New_Accept_Thread, NULL, 512, 2) == NULL)LWIP_ASSERT("tcpecho(): New Accept Task
netconn_close(newconn);netconn_delete(newconn);
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"
#if LWIP_NETCONN
#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)
{
for(;;)
{
err = netconn_write(newconn, text,
sizeof(text), NETCONN_COPY);
vTaskDelay(100);
}
}
}
static void
tcpecho_thread(void *arg)
{
struct netbuf *buf;
void *data;
u16_t len;
LWIP_UNUSED_ARG(arg);
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn, IP_ADDR_ANY, 5000);
#endif /* LWIP_IPV6 */
LWIP_ERROR("tcpecho: invalid conn", (conn != NULL), return;);
netconn_listen(conn);
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);
netconn_close(newconn);
netconn_delete(newconn);
} // 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
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users
[Prev in Thread] | Current Thread | [Next in Thread] |