[Winpcap-users] select()

Gianluca Varenni gianluca.varenni at cacetech.com
Fri Feb 16 18:43:00 GMT 2007


  ----- Original Message ----- 
  From: Jonathan Hunt 
  To: winpcap-users at winpcap.org 
  Sent: Friday, February 16, 2007 8:48 AM
  Subject: Re: [Winpcap-users] select()


  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:

      while(TRUE) {
          while(clientstate < STREAMING) { 
              if(WaitForSingleObject(pcap_getevent(skinny),0)==WAIT_OBJECT_0) {
                  if(skinny_received = pcap_next_ex(skinny, &skinny_header, &skinny_data) > 0) {

  (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.) 

  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++. 

  Any advice would be much appreciated - hopefully it's just a stupid oversight on my part.

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.

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().

Hope it helps
GV


  Thanks

  Jonathan





  On 07/02/07, Gianluca Varenni <gianluca.varenni at cacetech.com> wrote:
    Jonathan,

    you need to call pcap_getevent() and obtain a HANDLE you can wait on with
    WaitForSingleObject or WaitForMultipleObjects().

    You cannot obtain a file descriptor and use a select() on windows.

    Have a nice day
    GV

    ----- Original Message -----
    From: "Jonathan Hunt" <jgwehunt at gmail.com>
    To: <winpcap-users at winpcap.org >
    Sent: Wednesday, February 07, 2007 3:19 PM
    Subject: [Winpcap-users] select()


    > Here's a quick question:
    >
    > Using WinPcap 4, is it possible to call select() or poll() or  something 
    > to that effect to tell me when there is data to be read on  a pcap
    > "socket"?
    >
    > Many thanks
    >
    > Jonathan
    > _______________________________________________
    > Winpcap-users mailing list 
    > Winpcap-users at winpcap.org
    > https://www.winpcap.org/mailman/listinfo/winpcap-users

    _______________________________________________
    Winpcap-users mailing list
    Winpcap-users at winpcap.org
    https://www.winpcap.org/mailman/listinfo/winpcap-users





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


  _______________________________________________
  Winpcap-users mailing list
  Winpcap-users at winpcap.org
  https://www.winpcap.org/mailman/listinfo/winpcap-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20070216/fda6e0c7/attachment.htm


More information about the Winpcap-users mailing list