c – 阻塞和非阻塞读取有什么区别?

将等待/无等待指示符的概念添加到上述问题中作为TCP / IP或UDP环境中的ReadMessage函数的参数.

第三方功能描述指出:

This function is used to read a message from a queue which was defined by a previous registerforinput call. The input wait/no wait indicator will determine if this function will block on the queue specified, waiting for the data to be placed on the queue. If the nowait option is specified and no data is available a NULL pointer will be returned to the caller. When data available this function will return a pointer to the data read from the queue.

函数阻塞或非阻塞是什么意思?

最佳答案
阻止意味着您的代码(在该线程中)的执行将在调用期间停止.实质上,在阻塞操作完成之前,函数调用不会返回.

阻塞读取将等待,直到有可用数据(或超时,如果有的话,到期),然后从函数调用返回.非阻塞读取将(或至少应该)立即返回,但如果当前没有数据,则可能不会返回任何数据.

转载注明原文:c – 阻塞和非阻塞读取有什么区别? - 代码日志