请教lwip中的 tcp_arg 函数的功能
在stm32 lwip的例程中的:
static err_t HelloWorld_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
....
/* Tell LwIP to associate this structure with this connection. */
tcp_arg(pcb, mem_calloc(sizeof(struct name), 1));
....
}
然后在 static err_t HelloWorld_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) 中
struct name *name = (struct name *)arg;
这里不是很明白,为什么要将arg和name连结起来,为什么不能在HelloWorld_recv 直接定义name的相关变量和结构体?HelloWorld_recv中不是在pbuf中拿出相关的东西来用吗?
谢谢。
|