uisrc 发表于 2016-6-5 17:51:16

在嵌入式系统里面如何实现Callback函数

/** Function prototype for tcp accept callback functions. Called when a new
* connection can be accepted on a listening pcb.
*
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
* @param newpcb The new connection pcb
* @param err An error code if there has been an error accepting.
*            Only return ERR_ABRT if you have called tcp_abort from within the
*            callback function!
*/
typedef err_t (*tcp_accept_fn)(void *arg, struct tcp_pcb *newpcb, err_t err);

/** Function prototype for tcp receive callback functions. Called when data has
* been received.
*
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
* @param tpcb The connection pcb which received data
* @param p The received data (or NULL when the connection has been closed!)
* @param err An error code if there has been an error receiving
*            Only return ERR_ABRT if you have called tcp_abort from within the
*            callback function!
*/
typedef err_t (*tcp_recv_fn)(void *arg, struct tcp_pcb *tpcb,
                           struct pbuf *p, err_t err);

/** Function prototype for tcp sent callback functions. Called when sent data has
* been acknowledged by the remote side. Use it to free corresponding resources.
* This also means that the pcb has now space available to send new data.
*
* @param arg Additional argument to pass to the callback function (@see tcp_arg())
* @param tpcb The connection pcb for which data has been acknowledged
* @param len The amount of bytes acknowledged
* @return ERR_OK: try to send some data by calling tcp_output
*            Only return ERR_ABRT if you have called tcp_abort from within the
*            callback function!
*/
typedef err_t (*tcp_sent_fn)(void *arg, struct tcp_pcb *tpcb,
                              u16_t len);

页: [1]
查看完整版本: 在嵌入式系统里面如何实现Callback函数