[Winpcap-users] select()

Bryan Kadzban bryan at kadzban.is-a-geek.net
Fri Feb 16 18:38:40 GMT 2007


On Fri, Feb 16, 2007 at 04:48:37PM +0000, Jonathan Hunt wrote:
>            if(WaitForSingleObject(pcap_getevent(skinny),0)==WAIT_OBJECT_0)
> 
> For some reason WaitForSingleObject never returns WAIT_OBJECT_0 (it always
> returns 0x102).

Look here:

http://msdn2.microsoft.com/en-us/library/ms687032.aspx

In particular, the return value of WaitForSingleObject is WAIT_TIMEOUT
(that is, 0x102) if the timeout that you pass it elapses before the
object becomes signaled.

Your call passes zero for a timeout; that same page says:

> If dwMilliseconds is zero, the function tests the object's state and
> returns immediately. If dwMilliseconds is INFINITE, the function's
> time-out interval never elapses.

So you're telling WaitForSingleObject to check the object's state (since
you're passing a zero for dwMilliseconds) and return WAIT_TIMEOUT unless
it's signaled.  I bet it's never signaled at the instant you make this
call, and that's why you keep getting WAIT_TIMEOUT back.

You should use INFINITE for the timeout parameter, not 0.  If you use
any value other than INFINITE, you will need to handle timeouts.

(I believe INFINITE is defined to 0xffffffff, but I am not sure on that;
just use the symbolic name, and the compiler will take care of it.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winpcap.org/pipermail/winpcap-users/attachments/20070216/611e7895/attachment.pgp


More information about the Winpcap-users mailing list