Two ways to achieve this goal:
- Use select api.
- Use WSAEventSelect and WSAWaitForMultipleEvents. This method is recommended, for we can add a cancellable event along with the socket for polling like GCancellable structure in glib. Cancellable architecture responds smarter than tangible waiting for the ending of sub-modules.
refer to:
gstreamer/subprojects/glib/gio/gsocket.c:g_socket_condition_timed_wait
https://blog.csdn.net/qq_30145355/article/details/78379969