[Winpcap-users] sleep in pcap_next_ex api

Prasanna Kumar Nelam prasannakumar.n at imimobile.com
Tue Jul 14 03:27:55 PDT 2009

Dear All,


I am using pcap_next_ex() API to read the packets from Network. In my
application I implemented 2 threads one for reading the packets from
network, and other for process these packets.

I am giving the code snippet, can u please suggest me whether it is correct
or not.







The lines below are used to copy the captured pkt into our local buffer


packet_capture *packet=new packet_capture();









                        The following lines are used to put the packet into
queue, the packets from this C++queue are read by another thread 


                                    CAutoLock lock(g_syncpkt);


                                    printf("\n the queue size







                        printf("Error reading the packets: %s\n",

                        FILE *fp;


                        fprintf(fp,"%s-%s\n","Error reading the packets",








My doubt is it correct to write Sleep() at the
while((res=pcap_next_ex(pcap.m_padhandle,&header,&pkt_data))>0) loop, by
putting the sleep shall we loss any packet.


Before intrducing the Sleep() in the code, I am getting delayed processing
thread, and I am not able to process the packets immediately after
capturing, because of that the virtual memory is increasing.

Thanks in Advance for your advice.




Thanks and Regds,

Prasanna Kumar.N,

Software Engineer,

R&D Networks,





This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error, please notify the sender
immediately by e-mail and delete this e-mail from your system.  The sender
therefore does not accept liability for any errors or omissions in the
contents of this message, which arise as a result of e-mail transmission.
Please note that any views or opinions presented in this email are solely
those of the author and do not necessarily represent those of the company.
Finally, the recipient should check this email and any attachments for the
presence of viruses. The company accepts no liability for any damage caused
by any attachment with this email. 
IMImobile, Plot No:770, Road No : 44, Jubilee Hills, Hyderabad, India,
500033. www.imimobile.com <http://www.imimobile.com/>  
This e-mail message has been scanned for Viruses and Content and cleared by
Symantec Mail Security


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20090714/97db8f6f/attachment.htm 

More information about the Winpcap-users mailing list