`
yidongkaifa
  • 浏览: 4063949 次
文章分类
社区版块
存档分类
最新评论

lwIP(V1.0.0) RAW API函数源码分析4----tcp_accept()函数

 
阅读更多

位于:位于:lwip-x.x.x/src/core/tcp.c

原型: void tcp_accept(struct tcp_pcb *pcb,

err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err))

功能:指定处于监听状态的连接接通后将要调用的回调函数

函数源码:

/**
 * Used for specifying the function that should be called when a
 * LISTENing connection has been connected to another host.
 *处于监听状态的连接接通后,指定的函数被调用.
 * @param pcb tcp_pcb to set the accept callback
 * @param accept callback function to call for this pcb when LISTENing
 *        connection has been connected to another host
 */
void
tcp_accept(struct tcp_pcb *pcb,
     err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err))
{
  ((struct tcp_pcb_listen *)pcb)->accept = accept;
}

分析:将用户编写的一个函数的指针赋给处于监听状态tcp_pcb结构体中的一个参数,当处于监听状态的连接接通后,这个函数会被调用.虽然lwIP为应用嵌入式系统做了大量的精简工作,但结构体tcp_pcb还是一个庞大而复杂的数据结构,为了便于理解lwIP,对这个结构体下一番功夫还是很有必要的.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics