[Winpcap-users] Question about operation of pcap_next_ex () innon-blocking mode...

Gianluca Varenni gianluca.varenni at cacetech.com
Fri May 11 17:16:17 GMT 2007

  ----- Original Message ----- 
  From: Samir Sawhney 
  To: winpcap-users at winpcap.org 
  Sent: Monday, May 07, 2007 2:00 AM
  Subject: [Winpcap-users] Question about operation of pcap_next_ex () innon-blocking mode...


  I am using the winpcap 4.0 library to send and receive 
  TCP/IP packets to/from a demo application running on a 
  Windows 2000/XP computer.

  From an earlier post, I learnt that setting the 
  'read_timeout' parameter of pcap_open () to -1 causes 
  pcap_next_ex () to exhibit non-blocking behavior.

  In such a (non-blocking) configuration, what are the 
  parameters that determine when packets are copied out from 
  the kernel buffers into the user buffers (where they can be 
  retrieved via the pcap_next_ex () call)? 

pcap_next_ex becomes a polling function: it will return immediately, even if there are no available packets. It's something that you definitely want to avoid if possible.

  Is the 
  pcap_setmintocopy () call still relevant in such a (non-
  blocking) configuration? 

the mintocopy value is not relevant as far as pcap_next_ex() is concerned. It's still in use if you obtain the read event handle (pcap_getevent()), and wait on it before receiving packets. This event gets signalled when at least mintocopy bytes are available in the kernel capture buffer.

   What role does the 
  PCAP_OPENFLAG_MAX_RESPONSIVENESS flag (specified in the 
  'flags' parameter in the call to pcap_open ()) play?

PCAP_OPENFLAG_MAX_RESPONSIVENESS sets the mintocopy value to 0. If you set a mintocopy to 0 and a timeout > 0, pcap_next_ex() will block until the timeout elapses or at least one packet has been received.

  Also, one of the papers at this site talks about an API
  call to set the size of the user buffer.  However, I
  wasn't able to find any such function in the WinPcap
  documentation.  Can you please point me to the relevant

The function is called pcap_setuserbuffer() (int pcap_setuserbuffer(pcap_t *p, int size)). It's exported by WinPcap but it has never been documented.

Have a nice day



  8:00? 8:25? 8:40? Find a flick in no time
  with theYahoo! Search movie showtime shortcut.


  Winpcap-users mailing list
  Winpcap-users at winpcap.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20070511/fdc433a6/attachment.htm

More information about the Winpcap-users mailing list