我尝试使用lwip包中的原始tcp api创建简单的应用程序。 所以,这是我的代码的一部分:
err_t net_dg_accept(void *arg, struct tcp_pcb *con, err_t e)
{
stm_debug("netdebug: accepting connection");
const char *msg_t = "This is test debug message";
tcp_write(con, msg_t, sizeof(msg_t),TCP_WRITE_FLAG_COPY);
tcp_close(con);
}
void net_dg_thread ()
{
stm_debug("netdebug: thread is starting");
thrd_pcb = tcp_new();
if (thrd_pcb != NULL)
{
stm_debug("netdebug: thread_pcb was created");
err_t e;
e = tcp_bind(thrd_pcb, IP_ADDR_ANY, 22);
if (e == ERR_OK)
{
stm_debug("netdebug: thread_pcb was binded!");
lpcb = tcp_listen(thrd_pcb);
stm_debug("netdebug: thread_pcb was put into listenning mode!");
tcp_accept(lpcb,net_dg_accept);
stm_debug("netdebug: ?");
}
else
{
stm_debug("netdebug: error while binding thread_pcb!");
}
}
else
{
stm_debug("netdebug: error while creating thread_pcb!");
}
}
我尝试连接到22端口,但我什么都没得到。从串口调试中我得到thrd_pcb成功进入监听模式。为什么会如此?