How to interrupt a call selection in windows?

I know this is probably the main question, but I would like to hear a better way to understand this.

So to the problem. I have a driver thread using a call to select, and I have a GUI thread that sometimes requires interrupting the selection by writing to some file descriptor within the same process (FD GUI or something else). I used the handset on UNIX, but I did not have sockets for Windows, so I'm not sure which FD I should use. An example is very important, but not required).

Thanks.

+4
source share
2 answers

select() not suitable for asynchronous I / O under Windows. unfortunately, calling select() on windows only works with socket descriptors, not pipe or fie handles.

You should take a look at overlapping I / O.

using an event in your overlapping structure you can have behavior close to select() . any event on the socket raises an event that you can expect using WaitForMultipleObjects() . Now your GUI thread can signal an I / O stream by specifying a specific (separate) event that you create with a call to CreateEvent() .

+2
source

You can set a timeout shorter to choose from, and then cycle a round if it is a timeout. Or you can send a simple packet to the selected socket so that it wakes up.

0
source

Source: https://habr.com/ru/post/1343521/


All Articles