The callback function is used in the interlayer collaboration. The upper layer retains the address of one function of this layer in the lower layer (this function is the callback function), and the lower layer triggers the callback function under certain conditions, such as a drive, is a bottom layer, he is receiving When it comes to a data, in addition to completing the processing of this layer, the function will be called by the callback function address, which is handed over to the function of the upper layer application layer to perform further processing.
This is common in layered data communications.
The callback and the API are very close, and their commonality is a function of cross-layer calls. but
The difference is that the API is a low-level call. Generally, this function is known to the high level; while the callback is just the opposite, he is a high-level call. For the low level, he is unknown, this must be installed by the high level, this must be installed The installation function is actually a low-level API. After the installation is installed, the name of this callback is not known, but it saves this callback function through a function pointer. When you need to call, just reference this function pointer and related parameter pointer.
In fact: The callback is the function written on the high-level, and the low layer saves this function through a function pointer. Under the trigger of an event, the low layer calls the high layer function by the function pointer.