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 8694343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:45:56+00:00 2026-06-13T00:45:56+00:00

How can I detect if any network adapter is connected? I can only find

  • 0

How can I detect if any network adapter is connected? I can only find examples on using NSReachability to detect an internet connection, but I want to detect even a non-internet network connection. Getting the IP-adress on eth0 should work? I’m working on Mac only.

  • 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-13T00:45:58+00:00Added an answer on June 13, 2026 at 12:45 am

    Getting a List of All IP Addresses in Apple’s Technical Note TN1145 mentions 3 methods for getting the status of the network interfaces:

    • System Configuration Framework
    • Open Transport API
    • BSD sockets

    System Configuration Framework: This is Apple’s recommended way and there is sample code in the TN1145. The advantage is that it provides a way to get notified of changes in the interface configuration.

    Open Transport API: There is also sample code in TN1145, otherwise I cannot say much about it. (There is only “legacy” documentation on the Apple website.)

    BSD sockets: This seems to be the easiest way to get the list of interfaces and to determine the connection status (if you don’t need dynamic change notifications).

    The following code demonstrates how to find all IPv4 and IPv6 interfaces that are “up and running”.

    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <ifaddrs.h>
    #include <net/if.h>
    #include <netdb.h>
    
    struct ifaddrs *allInterfaces;
    
    // Get list of all interfaces on the local machine:
    if (getifaddrs(&allInterfaces) == 0) {
        struct ifaddrs *interface;
    
        // For each interface ...
        for (interface = allInterfaces; interface != NULL; interface = interface->ifa_next) {
            unsigned int flags = interface->ifa_flags;
            struct sockaddr *addr = interface->ifa_addr;
    
            // Check for running IPv4, IPv6 interfaces. Skip the loopback interface.
            if ((flags & (IFF_UP|IFF_RUNNING|IFF_LOOPBACK)) == (IFF_UP|IFF_RUNNING)) {
                if (addr->sa_family == AF_INET || addr->sa_family == AF_INET6) {
    
                    // Convert interface address to a human readable string:
                    char host[NI_MAXHOST];
                    getnameinfo(addr, addr->sa_len, host, sizeof(host), NULL, 0, NI_NUMERICHOST);
    
                    printf("interface:%s, address:%s\n", interface->ifa_name, host);
                }
            }
        }
    
        freeifaddrs(allInterfaces);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way that you can detect the resizeHandlers moment of completion? something
A there any g++ options which can detect improper initialization of std::string with NULL
Is there any way that I can detect browser type on routing and use
Is there any way I can detect when a line break has been erased
Is there a single preprocessor token that can be used to detect any iPhone
How can I detect HTTP method in CodeIgniter controller class? Edited: Is there any
For some reason I can't detect I can't set a z index for any
Are there any HTTP headers one can use to detect a mobile users number
Can you please tell me if there is any library/API to detect if user
Wondering if there is any tool that can help me to detect a pronoun's

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.