c_cpp #Check Network Status.c

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp #Check Network Status.c相关的知识,希望对你有一定的参考价值。

import SystemConfiguration

func isConnectedToNetwork() -> Bool {
    var zeroAddress = sockaddr_in()
    zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
    zeroAddress.sin_family = sa_family_t(AF_INET)
    let defaultRouteReachability = withUnsafePointer(&zeroAddress) {
        SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
    }
    var flags = SCNetworkReachabilityFlags.ConnectionAutomatic
    if !SCNetworkReachabilityGetFlags(defaultRouteReachability!, &flags) {
        return false
    }
    let isReachable = (flags.rawValue & UInt32(kSCNetworkFlagsReachable)) != 0
    let needsConnection = (flags.rawValue & UInt32(kSCNetworkFlagsConnectionRequired)) != 0
    return (isReachable && !needsConnection)
}

以上是关于c_cpp #Check Network Status.c的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp 快速代码片段,用于在统计(阻止)/ dev / rdsk中的设备时验证fstat64和stat64的行为。

Check Point SSL Network Extender 适用于 FF,而非 Safari,适用于 Mountain Lion

Initialization failed for ‘https://start.spring.io’ Please check URL, network and proxy settings

Initialization failed for ‘https://start.spring.io’ Please check URL, network and proxy settings

Initalization failed for ‘https://start.spring.io‘.Please check URL, network and proxy settings的解决方案

监控文件是否更新