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,对这个结构体下一番功夫还是很有必要的.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值