代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony/communication_netmanager_base 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
The NetManager module is a tailorable component of the Telephony subsystem. Key components of the module include NetConnService (connection management), NetPolicyService (policy management), NetStatsService (traffic management), TetheringService (network sharing), VpnService (VPN management), and EtherNetService (Ethernet connection).
Figure 1 NetManager architecture
foundation/communication/netmanager_base/
├─figures // Architecture
├─frameworks // Framework layer
│ ├─js // JavaScript APIs
│ └─native // Native APIs
├─interfaces // API definitions
│ ├─innerkits // JavaScript APIs
│ └─kits // Native APIs
├─sa_profile // SA profile
├─services // IPC server-side implementation
├─test // Test code
└─utils // Utilities
Type | API | Description |
---|---|---|
ohos.net.connection | function getDefaultNet(callback: AsyncCallback<NetHandle>): void; | Creates a NetHandle object that contains the netId of the default network. This function uses an asynchronous callback to return the result. |
ohos.net.connection | function getDefaultNet(): Promise<NetHandle>; | Creates a NetHandle object that contains the netId of the default network. This function uses a promise to return the result. |
ohos.net.connection | function getConnectionProperties(netHandle: NetHandle, callback: AsyncCallback<ConnectionProperties>): void; | Queries link information of the default network. This function uses an asynchronous callback to return the result. |
ohos.net.connection | function getConnectionProperties(netHandle: NetHandle): Promise<ConnectionProperties>; | Queries link information of the default network. This function uses a promise to return the result. |
ohos.net.connection | function getNetCapabilities(netHandle: NetHandle, callback: AsyncCallback<NetCapabilities>): void; | Queries the capability set of the default network. This function uses an asynchronous callback to return the result. |
ohos.net.connection | function getNetCapabilities(netHandle: NetHandle): Promise<NetCapabilities>; | Queries the capability set of the default network. This function uses a promise to return the result. |
ohos.net.connection | function hasDefaultNet(callback: AsyncCallback<boolean>): void; | Checks whether the default network is available. This function uses an asynchronous callback to return the result. |
ohos.net.connection | function hasDefaultNet(): Promise<boolean>; | Checks whether the default network is available. This function uses a promise to return the result. |
ohos.net.connection | function getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void; | Obtains all IP addresses of the default network by resolving the domain name. This function uses an asynchronous callback to return the result. |
ohos.net.connection | function createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection; | Creates a NetConnection object. netSpecifier specifies the network, and timeout specifies the timeout interval. timeout is configurable only when netSpecifier is specified. If neither of them is present, the default network is used. |
ohos.net.connection | function getAddressesByName(host: string): Promise<Array<NetAddress>>; | Obtains all IP addresses of the default network by resolving the domain name. This function uses a promise to return the result. |
ohos.net.connection.NetHandle | getAddressesByName(host: string, callback: AsyncCallback<Array<NetAddress>>): void; | Obtains all IP addresses of the specified network by resolving the domain name. This function uses an asynchronous callback to return the result. |
ohos.net.connection.NetHandle | getAddressesByName(host: string): Promise<Array<NetAddress>>; | Obtains all IP addresses of the specified network by resolving the domain name. This function uses a promise to return the result. |
ohos.net.connection.NetHandle | getAddressByName(host: string, callback: AsyncCallback<NetAddress>): void; | Obtains an IP address of the specified network by resolving the domain name. This function uses an asynchronous callback to return the result. |
ohos.net.connection.NetHandle | getAddressByName(host: string): Promise<NetAddress>; | Obtains an IP address of the specified network by resolving the domain name. This function uses a promise to return the result. |
ohos.net.connection.NetConnection | on(type: 'netAvailable', callback: Callback<NetHandle>): void; | Listens to netAvailable events. |
ohos.net.connection.NetConnection | on(type: 'netCapabilitiesChange', callback: Callback<{ netHandle: NetHandle, netCap: NetCapabilities }>): void; | Listens to netCapabilitiesChange events. |
ohos.net.connection.NetConnection | on(type: 'netConnectionPropertiesChange', callback: Callback<{ netHandle: NetHandle, connectionProperties: ConnectionProperties }>): void; | Listens to netConnectionPropertiesChange events. |
ohos.net.connection.NetConnection | on(type: 'netLost', callback: Callback<NetHandle>): void; | Listens to netLost events. |
ohos.net.connection.NetConnection | on(type: 'netUnavailable', callback: Callback<void>): void; | Listens to netUnavailable events. |
ohos.net.connection.NetConnection | register(callback: AsyncCallback<void>): void; | Registers an observer for the default network or the network specified in createNetConnection. |
ohos.net.connection.NetConnection | unregister(callback: AsyncCallback<void>): void; | Unregisters the observer for the default network or the network specified in createNetConnection. |
import net_connection from "@ohos.net.connection"
net_connection.getAddressesByName("www.example.com").then(function (addresses) {
console.log(JSON.stringify(addresses))
})
import net_connection from "@ohos.net.connection"
let netConnection = net_connection.createNetConnection()
netConnection.on('netAvailable', function(data) {
console.log(JSON.stringify(data))
})
netConnection.register(function (error) {
if (error) {
console.log(JSON.stringify(error))
}
})
Network Management Subsystem
communication_netmanager_base
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。