Extract Network Interface Information

Source: Internet
Author: User
Extract Network Interface Information

The two main functions are getnumberofinterfaces and getinterfaceinfo. The former indicates the number of network interfaces, and the latter extracts information about network interfaces. One thing to note about the first function is that it does not seem to return the correct value, because according to msdn: a network interface is the logical abstraction of the network card, and they are a one-to-one relationship. The actual situation is that there is only one Nic on my machine, but this function returns 2. In fact, each system attaches a network interface for debugging. The IP address of this interface is 127.0.0.1, And the subnet mask is 255.0.0.0. This result can beProgram. The ip_interface_info structure returned by getinterfaceinfo also contains a numadapters integer data field that records the correct Nic. Then, you must note that getinterfaceinfo must be called twice to obtain the buffer size for the first time and the value for the second time. Again, what makes me feel strange is that the ip_interface_info returned by getinterfaceinfo does not use the linked list instead of the above structure, but uses the dynamic array method (which linear structure is used up now ), thereforeCodeTo:

For (INT I = 0; inumadapters; I ++)
{
Cout

  • Previous:Easily implement Internet filtering in Linux
  • Next article:Ajax development using Ajax. dll
  • 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.