harmony 鸿蒙NetConn_NetConnCallback

  • 2025-06-12
  • 浏览 (5)

NetConn_NetConnCallback

Overview

Defines network status callbacks.

Since: 12

Related module: NetConnection

Header file: net_connection_type.h

Summary

Member Variables

Name Description
onNetworkAvailable Called when the network is available.
onNetCapabilitiesChange Called when the network capabilities change.
onConnetionProperties Called when network connection properties change.
onNetLost Called when the network is disconnected.
onNetUnavailable Called when the network is unavailable. This callback is triggered when the network is not activated within the specified timeout interval. If the timeout interval is not set, this callback is not triggered.

Member Variable Description

onNetworkAvailable

typedef void (*OH_NetConn_NetworkAvailable)(NetConn_NetHandle *netHandle)

Description

Called when the network is available.

Description

After the callback is complete, the parameter memory is automatically cleared and therefore the parameter pointer should be released.

Parameters

Name Type Description
netHandle NetHandle Network handle.

onNetCapabilitiesChange

typedef void (*OH_NetConn_NetCapabilitiesChange)(NetConn_NetHandle *netHandle, NetConn_NetCapabilities *netCapabilities)

Description

Called when the network capabilities change.

Description

After the callback is complete, the parameter memory is automatically cleared and therefore the parameter pointer should be released.

Parameters

Name Type Description
netHandle NetHandle Network handle.
netCapabilities NetCapabilities Network capabilities.

onConnetionProperties

typedef void (*OH_NetConn_NetConnectionPropertiesChange)(NetConn_NetHandle *netHandle, NetConn_ConnectionProperties *connConnetionProperties)

Description

Called when network connection properties change.

Description

After the callback is complete, the parameter memory is automatically cleared and therefore the parameter pointer should be released.

Parameters

Name Type Description
netHandle NetHandle Network handle.
connConnetionProperties ConnectionProperties Network connection properties.

onNetLost

typedef void (*OH_NetConn_NetLost)(NetConn_NetHandle *netHandle)

Description

Called when the network is disconnected.

Description

After the callback is complete, the parameter memory is automatically cleared and therefore the parameter pointer should be released.

Parameters

Name Type Description
netHandle NetHandle Network handle.

onNetUnavailable

typedef void (*OH_NetConn_NetUnavailable)(void)

Description

Called when the network is unavailable. This callback is triggered when the network is not activated within the specified timeout interval. If the timeout interval is not set, this callback is not triggered.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Network Kit

harmony 鸿蒙NetConn_ConnectionProperties

harmony 鸿蒙NetConn_HttpProxy

harmony 鸿蒙NetConn_NetAddr

harmony 鸿蒙NetConn_NetCapabilities

harmony 鸿蒙NetConn_NetHandle

harmony 鸿蒙NetConn_NetHandleList

harmony 鸿蒙NetConn_NetSpecifier

harmony 鸿蒙NetConn_Route

harmony 鸿蒙NetConnection

0  赞