enum tcp_state {
CLOSED = 0, //连接断开没有连接
LISTEN = 1, //服务器进入侦听状态
SYN_SENT = 2, //连接请求已发送等待确认
SYN_RCVD = 3, //已接收到对方的连接请求
ESTABLISHED = 4, //连接已建立
FIN_WAIT_1 = 5, //程序以关闭连接
FIN_WAIT_2 = 6, //另一端程序已关闭连接
CLOSE_WAIT = 7, //等待程序关闭连接
CLOSING = 8, //两端同时收到对方关闭连接请求
LAST_ACK = 9, //服务器等待对方接受关闭请求
TIME_WAIT = 10 //关闭成功等待网络中可能出现得到剩余数据
};
LWIP的回调函数
#if LWIP_CALLBACK_API
/* Function to be called when more send buffer space is available. */
tcp_sent_fn sent;
/* Function to be called when (in-sequence) data has arrived. */
tcp_recv_fn recv;
/* Function to be called when a connection has been set up. */
tcp_connected_fn connected;
/* Function which is called periodically. */
tcp_poll_fn poll;
/* Function to be called whenever a fatal error occurs. */
tcp_err_fn errf;
#endif /* LWIP_CALLBACK_API */
本文详细介绍了LWIP中TCP连接的状态转换,包括从连接断开到连接建立的各种状态,并列举了LWIP提供的用于处理TCP事件的回调函数,如连接建立、数据接收等。
697

被折叠的 条评论
为什么被折叠?



