Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8149451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:51:18+00:00 2026-06-06T14:51:18+00:00

Why is it that after the pcap_loop function has been called, I must wait

  • 0

Why is it that after the pcap_loop function has been called, I must wait several seconds to capture the first packets?

void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);

int main(int argc, char * argv[])
{
    pcap_t * handle;
    char dev_name[] = "en0";
    char err_buf[PCAP_ERRBUF_SIZE];

    handle = pcap_open_live(dev_name, 4096, 1, 0, err_buf);

    if (handle == NULL) {
        fprintf(stderr, "Couldn't open device %s: %s\n" , dev_name , err_buf);
        exit(1);
    }

    pcap_loop(handle, 1, print_packet, NULL);
    pcap_close(handle);

    exit(0);
}

void print_packet(u_char * args, const struct pcap_pkthdr * hdr, const u_char * buff)
{
    /* ... */
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:51:19+00:00Added an answer on June 6, 2026 at 2:51 pm

    I’ve found the problem by reading pcap_open_live documentation:

    pcap_t *pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *errbuf)
    

    […] to_ms specifies the read timeout in milliseconds. The read
    timeout is used to arrange that the read not necessarily return immediately when a packet is seen,
    but that it wait for some amount of time to allow more packets to arrive and to read multiple packets
    from the OS kernel in one operation. Not all platforms support a read timeout; on platforms that
    don’t, the read timeout is ignored. A zero value for to_ms, on platforms that support a read time-
    out, will cause a read to wait forever to allow enough packets to arrive, with no timeout. […]

    Source.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have noticed that after my Grails app has been deployed for about 2
I'm finding that after my app has been in the background for a while,
I have read several times that after you delete a row in an InnoDB
Let's say that after BeginRead is called, there is other code that will ultimately
My understanding is that after initializing all frames and widgets in the __init__ method,
I noticed that after I quit an app using the back button, when I
I've found that after changing the overlays on a MapView , the changes aren't
I have noticed that after awhile of debug/tweakcode/debug etc that eventually Silverlight starts to
I've noticed that after I log in with Django registration it redirects me to
Can anyone confirm that after changing the Apple Push Certificate to follow the new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.