- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我尝试使用 LwIP netconn API(在 stm32f4 发现板上)建立多个同时连接。他们都在自己的线程中并且完美地工作。但由于某种原因,同一时间只能建立一个连接。
我的代码基于 ST 回显服务器示例,如下所示:
void myTaskStart(void const * argument)
{
struct netconn *conn, *newconn;
err_t err, accept_err;
struct netbuf* buf;
void* data;
u16_t len;
err_t recv_err;
/* Create a new connection identifier. */
conn = netconn_new(NETCONN_TCP);
if (conn != NULL)
{
err = netconn_bind(conn, NULL, <some port>);
if (err == ERR_OK)
{
/* Tell connection to go into listening mode. */
netconn_listen(conn);
while (1)
{
/* Grab new connection. */
accept_err = netconn_accept(conn, &newconn);
/* Process the new connection. */
if (accept_err == ERR_OK)
{
<do stuff here>
netconn_close(newconn);
netconn_delete(newconn);
}
}
}
else
{
netconn_delete(newconn);
printf(" can not bind TCP netconn");
}
}
else
{
printf("can not create TCP netconn");
}
}
所有线程都在监听不同的端口。但是,如果已经建立了另一个使用不同端口的连接,则所有其他线程都会在 netconn_accept
处失败。它返回 ERR_ABRT
,这意味着 连接已中止:在接受期间超出 pcbs 或超出 netconns
。我在这里想念什么?
最佳答案
好的。我找到了解决方案。增加 MEMP_NUM_NETBUF 和 MEMP_NUM_NETCONN 使一切正常。
关于multithreading - 使用 netconn 同时处理多个 LwIP 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45190941/
我使用的是tm4c1294+lwip1.4.1+FreeRTOS。 当 netconn_alloc() 被调用用于套接字通信 时,它会分配一个未使用的信号量。信号量的个数定义为SYS_SEM_MAX,
我尝试使用 LwIP netconn API(在 stm32f4 发现板上)建立多个同时连接。他们都在自己的线程中并且完美地工作。但由于某种原因,同一时间只能建立一个连接。 我的代码基于 ST 回显服
当调用LwIP netconn_accept() 或netconn_recv() 函数时,如果我们使用的是RTOS,它会阻塞线程并等待连接直到超时或永远,取决于 LWIP_SO_RCVTIME0 的设
我正在尝试使用 lwip netconn API(使用 esp-open-rtos)为 ESP8266 编写简单的 SNTP 客户端。问题是我无法从服务器收到答案。 代码(没有错误检查和调试消息):
我一直在尝试在 STM32F4DISCOVERY 板中使用 LwIP 修改 tcp 服务器示例。我必须编写一个不一定必须回复服务器响应的发件人。例如,它可以以 100 毫秒的频率发送数据。 首先TCP
我正在使用 FreeRTOS + LwIP 开发基于以太网的床边护士调用设备。在阅读了一些示例和文档后,我想使用 LwIP 的 netconn API 在 TCP 下发送和接收数据,因为我不熟悉 BS
我目前正在使用 lwip 堆栈来实现 modbus 服务器,但“保持事件”功能不起作用。有人可以看看我的问题吗? 代码: static void prvweb_ParseHTMLRequest( st
我是一名优秀的程序员,十分优秀!