请教版主LWIP问题,
我的网页程序是10S刷新一次,但过一段时间后(10多分)就会在串口调试助手中发现这个Assertion "recv_tcp: recv for wrong pcb!" failed at line 201 in F:\h\stm107\STM32_F107_lwIP\lwIP\src\api\api_msg.c
然后再也访问不了网页了!
这个问题应该怎么解决呢?? while (1) {
newconn = netconn_accept(conn);
if (newconn != NULL) {
struct netbuf *buf;
void *data;
u16_t len;
while ((buf = netconn_recv(newconn)) != NULL) {
do {
netbuf_data(buf, &data, &len);
err = netconn_write(newconn, "<b>HELLO", 10, NETCONN_COPY);
err = netconn_write(newconn, data, len, NETCONN_COPY);
} while (netbuf_next(buf) >= 0);
netbuf_delete(buf);
}
printf("Got EOF, looping\n");
netconn_close(newconn);
netconn_delete(newconn);
}
}
}
我看例程中有这么一句话,
while((buf = netconn_recv(conn)) != NULL)
{
}
我写成这样的话连一次网页也访问不到,我觉得这句话不太对,第一次没问题可以进得去,可是执行完后再执行时,就因等待信号量而阻塞,执行不了后续的
netconn_close(conn);
netconn_delete(conn);
后来我把这个改为: if((buf = netconn_recv(conn)) != NULL)
while (1) {
/* Grab new connection. */
newconn = netconn_accept(conn);
printf("accepted new connection %p\n", newconn);
/* Process the new connection. */
if (newconn != NULL) {
struct netbuf *buf;
void *data;
u16_t len;
if((buf = netconn_recv(newconn)) != NULL) {
printf("Recved\n");
do {
netbuf_data(buf, &data, &len);
err = netconn_write(newconn, "<b>HELLO", 10, NETCONN_COPY);
err = netconn_write(newconn, data, len, NETCONN_COPY);
#if 0
if (err != ERR_OK) {
printf("tcpecho: netconn_write: error \"%s\"\n", lwip_strerr(err));
}
#endif
} while (netbuf_next(buf) >= 0);
netbuf_delete(buf);
}
printf("Got EOF, looping\n");
/* Close connection and discard connection identifier. */
netconn_close(newconn);
netconn_delete(newconn);
}
}
}
不知道这是不是问题所在?
页:
[1]