Libpcap programming, a strange problem

Source: Internet
Author: User
Libpcap programming is a strange problem-Linux general technology-Linux programming and kernel information. The following is a detailed description. Supplement: sometimes it can be executed, but the probability is low.
Online and so on. I posted it in the technical exchange edition. Nobody knows me. resend the post once. If you want to delete the post, delete it. this problem cannot be solved. it is the client of Digital China verification. if you are interested, you can communicate with each other.

In ubuntu7.10, I want to use libpcap to send/receive packets...

I wrote it in Xp. The program is okay.

Check the following code. // sorry, the program is in ubuntu and the dual system cannot access the Internet.
CODE: # include... // the header file is okay.
Int main ()
{
... // Initialization
While (1)
{
....
Printf ("send pkt... \ n"); // OK
Pcap_sendpacket (open_dev, pkt, sizeof (pkt);/OK
Prinf ("over"); // problem: Sometimes the program stops printing this sentence.
Break;
}
Printf ("waiting response ..... \ n "); // problem: Sometimes it stops here.
While (1)
{
// The following is the response packet
Pcap_next_ex (open_dev, hdr, recpkt );
....
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.