LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

WSAWaitForMultipleEvents does not apparantly cancel its event

I set up the event with the lines:

    hWSADataRecv = WSACreateEvent();
    intRetVal = WSAEventSelect(intUDPDataSocket, hWSADataRecv, FD_READ);
    intRetVal = CmtScheduleThreadPoolFunction
        (hEtherThreadPool, etherDataPortRecv , 0, &etherDataPortRecvThreadFunctionID);
 
and then in the thread use the lines:

    while(intQuitting == 0)
    {
       
        if((dwEvent = WSAWaitForMultipleEvents(1, &hWSADataRecv, TRUE, 100, FALSE))
                 == WSA_WAIT_EVENT_0)
         {

            if((intRetVal = WSARecvFrom(intUDPDataSocket, &DataBuf, 1, &dwBytesRecv, &dwFlags,
                                        (SOCKADDR *)&AddrDestData, &intAddrSize, &Overlapped, NULL)) < 0)

---------------------

This starts fine and waits for an incomming packet.
As soon as the first packet arrives WSAWaitForMultipleEvents fires as fast as it can and WSARecvFrom emits error 10035 (WSAWouldBlock).  The socket has been set to non blocking by WSAEventSelect.

In Sockets Help under WSAWaitForMultipleEvents, the comment below occurs:

no further actions are taken for that network event until the application makes the function call that implicitly reenables the setting of that network event and signaling of the associated event object.

What function call can I make to reset the event?

Thanks.
0 Kudos
Message 1 of 2
(3,753 Views)
Hi archieb,

I have a question about your inquiry. Is this behavior you are seeing different in CVI than it would be in other C compilers, or is this specific to winsock itself?

If this is specific to winsock itself, you may want to visit a forum where more experts to winsock will post. This forum is more for support specific to CVI and since winsock is part of the windows api and not cvi specific, you may have a better chance of finding your answers at one of the more general C or network programming forums. Some of these include:

http://www.experts-exchange.com/
http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=826&SiteID=1 - official microsoft winsock forums

Also, MSDN is a great place for help with windows api. As well as the following winsock tutorial.

http://johnnie.jerrata.com/winsocktutorial/

Brandon Vasquez | Software Engineer | Integration Services | National Instruments
0 Kudos
Message 2 of 2
(3,735 Views)