如果以阻塞的方式使用UDP,幾乎肯定要在一個線程中recvfrom,此時有可能出現錯誤10004,一個可能的原因是主線程先結束了。
下面是從網上找到的一點注釋:
下面是從網上找到的一點注釋:
Answer/Solution:A blocking operation was interrupted by a call to WSACancelBlockingCall. An asynchronous signal (such as SIGINT or SIGQUIT) was caught by the process during the execution of an interruptible function. If the signal handler performs a normal return, the interrupted function call will seem to have returned the error condition.
Developer suggestions: You need to be prepared to handle this error on any functions that reference blocking sockets, or any calls to blocking functions, if you allow the user to cancel a blocking call. Whether to handle it as a fatal error or non-fatal error depends on the application and the context, so it's up to you to decide.