<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=jgwehunt@gmail.com href="mailto:jgwehunt@gmail.com">Jonathan Hunt</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=winpcap-users@winpcap.org
href="mailto:winpcap-users@winpcap.org">winpcap-users@winpcap.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Friday, February 16, 2007 8:48
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Winpcap-users]
select()</DIV>
<DIV><BR></DIV>
<DIV>Hi again. I've been trying to get pcap_getevent() to work with
WaitForSingleObject(), but without success. Here's a code fragment which will
hopefully illustrate my problem:<BR><BR> while(TRUE)
{<BR> while(clientstate < STREAMING) {
<BR>
if(WaitForSingleObject(pcap_getevent(skinny),0)==WAIT_OBJECT_0)
{<BR>
if(skinny_received = pcap_next_ex(skinny,
&skinny_header, &skinny_data) > 0) {<BR><BR>(pcap_t *skinny has
been initialised with pcap_open() and then had a filter applied to it...the
code worked before I added the above pcap_getevent() section.) <BR><BR>For
some reason WaitForSingleObject never returns WAIT_OBJECT_0 (it always returns
0x102). I'm developing with Winpcap4.0 and XP Pro SP2, Visual Studio 2005
SP1...the compiler's set to compile it as C code, not C++. <BR><BR>Any advice
would be much appreciated - hopefully it's just a stupid oversight on my
part.<BR></DIV><FONT size=2></FONT></BLOCKQUOTE>
<DIV><FONT size=2>You have put 0 as a timeout value, so WaitForSingleObject
returns immediately, telling you if the event is signalled (WAIT_OBJECT_0)
or a timeout (of 0 ms) occurred. 0x102 is exactly
WAIT_TIMEOUT.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Why are you explicitely using a WaitForSingleObject?
pcap_next_ex embeds the same wait functionality internally. pcap_getevent() is
useful when you want to wait for multiple events using
WaitForMultipleObjects().</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Hope it helps</FONT></DIV>
<DIV><FONT size=2>GV</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT size=2></FONT> </DIV>
<DIV><BR>Thanks<BR><BR>Jonathan<BR><BR><BR><BR><BR></DIV>
<DIV><SPAN class=gmail_quote>On 07/02/07, <B class=gmail_sendername>Gianluca
Varenni</B> <<A
href="mailto:gianluca.varenni@cacetech.com">gianluca.varenni@cacetech.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Jonathan,<BR><BR>you
need to call pcap_getevent() and obtain a HANDLE you can wait on
with<BR>WaitForSingleObject or WaitForMultipleObjects().<BR><BR>You cannot
obtain a file descriptor and use a select() on windows.<BR><BR>Have a nice
day<BR>GV<BR><BR>----- Original Message -----<BR>From: "Jonathan Hunt"
<<A href="mailto:jgwehunt@gmail.com">jgwehunt@gmail.com</A>><BR>To:
<<A href="mailto:winpcap-users@winpcap.org">winpcap-users@winpcap.org
</A>><BR>Sent: Wednesday, February 07, 2007 3:19 PM<BR>Subject:
[Winpcap-users] select()<BR><BR><BR>> Here's a quick
question:<BR>><BR>> Using WinPcap 4, is it possible to call select()
or poll() or something <BR>> to that effect to tell me when
there is data to be read on a pcap<BR>>
"socket"?<BR>><BR>> Many thanks<BR>><BR>> Jonathan<BR>>
_______________________________________________<BR>> Winpcap-users
mailing list <BR>> <A
href="mailto:Winpcap-users@winpcap.org">Winpcap-users@winpcap.org</A><BR>>
<A
href="https://www.winpcap.org/mailman/listinfo/winpcap-users">https://www.winpcap.org/mailman/listinfo/winpcap-users</A><BR><BR>_______________________________________________<BR>Winpcap-users
mailing list<BR><A
href="mailto:Winpcap-users@winpcap.org">Winpcap-users@winpcap.org</A><BR><A
href="https://www.winpcap.org/mailman/listinfo/winpcap-users">https://www.winpcap.org/mailman/listinfo/winpcap-users</A><BR></BLOCKQUOTE></DIV><BR>
<P>
<HR>
<P></P>_______________________________________________<BR>Winpcap-users
mailing
list<BR>Winpcap-users@winpcap.org<BR>https://www.winpcap.org/mailman/listinfo/winpcap-users<BR></BLOCKQUOTE></BODY></HTML>