Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
4efbf52e
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4efbf52e
编写于
9月 04, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 04, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23710 修改net相关md文件
Merge pull request !23710 from 徐杰/feature_ex
上级
fe5ba3ee
7c0ca6dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
70 addition
and
28 deletion
+70
-28
zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
+4
-14
zh-cn/application-dev/reference/apis/js-apis-net-statistics.md
.../application-dev/reference/apis/js-apis-net-statistics.md
+3
-3
zh-cn/application-dev/reference/apis/js-apis-net-vpn.md
zh-cn/application-dev/reference/apis/js-apis-net-vpn.md
+55
-9
zh-cn/application-dev/reference/apis/js-apis-socket.md
zh-cn/application-dev/reference/apis/js-apis-socket.md
+8
-2
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-net-ethernet.md
浏览文件 @
4efbf52e
...
...
@@ -28,7 +28,7 @@ setIfaceConfig(iface: string, ic: InterfaceConfiguration, callback: AsyncCallbac
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------- | ---- | ------------------------------------------ |
| iface | string | 是 | 网络接口名 |
| ic |
[
InterfaceConfiguration
](
#interfaceconfiguration
)
| 是 | 要设置的网络接口配置信息 |
| ic |
[
InterfaceConfiguration
](
#interfaceconfiguration
9
)
| 是 | 要设置的网络接口配置信息 |
| callback | AsyncCallback
\<
void> | 是 | 回调函数,成功无返回,失败返回对应错误码。 |
**错误码:**
...
...
@@ -55,12 +55,7 @@ ethernet.setIfaceConfig("eth0", {
route
:
"
192.168.xx.xxx
"
,
gateway
:
"
192.168.xx.xxx
"
,
netMask
:
"
255.255.255.0
"
,
dnsServers
:
"
1.1.1.1
"
,
httpProxy
:
{
host
:
"
180.89.xx.xx
"
,
port
:
8080
,
exclusionList
:
{
"
example.com
"
,
"
192.168.0.1
"
}
}
dnsServers
:
"
1.1.1.1
"
},
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
"
setIfaceConfig callback error =
"
+
JSON
.
stringify
(
error
));
...
...
@@ -87,7 +82,7 @@ setIfaceConfig(iface: string, ic: InterfaceConfiguration): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------------------------------------------- | ---- | ------------------------ |
| iface | string | 是 | 接口名 |
| ic |
[
InterfaceConfiguration
](
#interfaceconfiguration
)
| 是 | 要设置的网络接口配置信息 |
| ic |
[
InterfaceConfiguration
](
#interfaceconfiguration
9
)
| 是 | 要设置的网络接口配置信息 |
**返回值:**
...
...
@@ -119,12 +114,7 @@ ethernet.setIfaceConfig("eth0", {
route
:
"
192.168.xx.xxx
"
,
gateway
:
"
192.168.xx.xxx
"
,
netMask
:
"
255.255.255.0
"
,
dnsServers
:
"
1.1.1.1
"
,
httpProxy
:
{
host
:
"
180.89.xx.xx
"
,
port
:
8080
,
exclusionList
:
{
"
example.com
"
,
"
192.168.0.1
"
}
}
dnsServers
:
"
1.1.1.1
"
}).
then
(()
=>
{
console
.
log
(
"
setIfaceConfig promise ok
"
);
}).
catch
(
error
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-net-statistics.md
浏览文件 @
4efbf52e
...
...
@@ -708,7 +708,7 @@ getTrafficStatsByIface(ifaceInfo: IfaceInfo, callback: AsyncCallback\<NetStatsIn
endTime
:
16859485670
}
statistics
.
getTrafficStatsByIface
(
ifaceInfo
),
(
error
,
statsInfo
)
=>
{
statistics
.
getTrafficStatsByIface
(
(
ifaceInfo
),
(
error
,
statsInfo
)
=>
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
"
getTrafficStatsByIface bytes of received =
"
+
JSON
.
stringify
(
statsInfo
.
rxBytes
));
console
.
log
(
"
getTrafficStatsByIface bytes of sent =
"
+
JSON
.
stringify
(
statsInfo
.
txBytes
));
...
...
@@ -761,7 +761,7 @@ getTrafficStatsByIface(ifaceInfo: IfaceInfo): Promise\<NetStatsInfo>;
endTime
:
16859485670
}
statistics
.
getTrafficStatsByIface
().
then
(
function
(
statsInfo
)
{
statistics
.
getTrafficStatsByIface
(
ifaceInfo
).
then
(
function
(
statsInfo
)
{
console
.
log
(
"
getTrafficStatsByIface bytes of received =
"
+
JSON
.
stringify
(
statsInfo
.
rxBytes
));
console
.
log
(
"
getTrafficStatsByIface bytes of sent =
"
+
JSON
.
stringify
(
statsInfo
.
txBytes
));
console
.
log
(
"
getTrafficStatsByIface packets of received =
"
+
JSON
.
stringify
(
statsInfo
.
rxPackets
));
...
...
@@ -814,7 +814,7 @@ getTrafficStatsByUid(uidInfo: UidInfo, callback: AsyncCallback\<NetStatsInfo>):
uid
:
20010037
}
statistics
.
getTrafficStatsByUid
(
uidInfo
),
(
error
,
statsInfo
)
=>
{
statistics
.
getTrafficStatsByUid
(
(
uidInfo
),
(
error
,
statsInfo
)
=>
{
console
.
log
(
JSON
.
stringify
(
error
))
console
.
log
(
"
getTrafficStatsByUid bytes of received =
"
+
JSON
.
stringify
(
statsInfo
.
rxBytes
));
console
.
log
(
"
getTrafficStatsByUid bytes of sent =
"
+
JSON
.
stringify
(
statsInfo
.
txBytes
));
...
...
zh-cn/application-dev/reference/apis/js-apis-net-vpn.md
浏览文件 @
4efbf52e
...
...
@@ -43,16 +43,16 @@ createVpnConnection(context: AbilityContext): VpnConnection
Stage模型示例:
```
ts
// 获取context
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
globalThis
.
context
=
this
.
context
;
// 获取context
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
globalThis
.
context
=
this
.
context
;
}
}
}
let
context
=
globalThis
.
context
;
VpnConnection
=
vpn
.
createVpnConnection
(
context
);
console
.
info
(
"
vpn onInit:
"
+
JSON
.
stringify
(
VpnConnection
));
let
context
=
globalThis
.
context
;
let
VpnConnection
=
vpn
.
createVpnConnection
(
context
);
console
.
info
(
"
vpn onInit:
"
+
JSON
.
stringify
(
VpnConnection
));
```
## VpnConnection
...
...
@@ -96,6 +96,14 @@ setUp(config: VpnConfig, callback: AsyncCallback\<number\>): void
**示例:**
```
js
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
globalThis
.
context
=
this
.
context
;
}
}
let
VpnConnection
=
vpn
.
createVpnConnection
(
globalThis
.
context
);
let
config
=
{
addresses
:
[{
address
:
{
...
...
@@ -160,6 +168,14 @@ setUp(config: VpnConfig): Promise\<number\>
**示例:**
```
js
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
globalThis
.
context
=
this
.
context
;
}
}
let
VpnConnection
=
vpn
.
createVpnConnection
(
globalThis
.
context
);
let
config
=
{
addresses
:
[{
address
:
{
...
...
@@ -220,6 +236,14 @@ protect(socketFd: number, callback: AsyncCallback\<void\>): void
```
js
import
socket
from
"
@ohos.net.socket
"
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
globalThis
.
context
=
this
.
context
;
}
}
let
VpnConnection
=
vpn
.
createVpnConnection
(
globalThis
.
context
);
var
tcp
=
socket
.
constructTCPSocketInstance
();
tcp
.
bind
({
address
:
"
0.0.0.0
"
,
...
...
@@ -283,6 +307,14 @@ protect(socketFd: number): Promise\<void\>
```
js
import
socket
from
"
@ohos.net.socket
"
;
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
globalThis
.
context
=
this
.
context
;
}
}
let
VpnConnection
=
vpn
.
createVpnConnection
(
globalThis
.
context
);
var
tcp
=
socket
.
constructTCPSocketInstance
();
tcp
.
bind
({
address
:
"
0.0.0.0
"
,
...
...
@@ -339,6 +371,13 @@ destroy(callback: AsyncCallback\<void\>): void
**示例:**
```
js
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
globalThis
.
context
=
this
.
context
;
}
}
let
VpnConnection
=
vpn
.
createVpnConnection
(
globalThis
.
context
);
VpnConnection
.
destroy
((
error
)
=>
{
console
.
info
(
JSON
.
stringify
(
error
));
})
...
...
@@ -376,6 +415,13 @@ destroy(): Promise\<void\>
**示例:**
```
js
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
class
EntryAbility
extends
UIAbility
{
onWindowStageCreate
(
windowStage
){
globalThis
.
context
=
this
.
context
;
}
}
let
VpnConnection
=
vpn
.
createVpnConnection
(
globalThis
.
context
);
VpnConnection
.
destroy
().
then
(()
=>
{
console
.
info
(
"
destroy success.
"
)
}).
catch
(
err
=>
{
...
...
zh-cn/application-dev/reference/apis/js-apis-socket.md
浏览文件 @
4efbf52e
...
...
@@ -1262,7 +1262,7 @@ getSocketFd(callback: AsyncCallback\<number\>): void
```
js
import
socket
from
"
@ohos.net.socket
"
;
var
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tunnelfd
=
0
tcp
.
bind
({
address
:
"
0.0.0.0
"
,
...
...
@@ -1302,7 +1302,7 @@ getSocketFd(): Promise\<number\>
```
js
import
socket
from
"
@ohos.net.socket
"
;
var
tcp
=
socket
.
constructTCPSocketInstance
();
let
tcp
=
socket
.
constructTCPSocketInstance
();
let
tunnelfd
=
0
tcp
.
bind
({
address
:
"
0.0.0.0
"
,
...
...
@@ -2936,6 +2936,7 @@ on(type: 'message', callback: Callback<{message: ArrayBuffer, remoteInfo: Socket
**示例:**
```
js
import
socket
from
'
@ohos.net.socket
'
;
let
tls
=
socket
.
constructTLSSocketInstance
();
let
messageView
=
''
;
tls
.
on
(
'
message
'
,
value
=>
{
...
...
@@ -2970,6 +2971,7 @@ off(type: 'message', callback?: Callback\<{message: ArrayBuffer, remoteInfo: Soc
**示例:**
```
js
import
socket
from
'
@ohos.net.socket
'
;
let
tls
=
socket
.
constructTLSSocketInstance
();
let
messageView
=
''
;
let
callback
=
value
=>
{
...
...
@@ -3003,6 +3005,7 @@ on(type: 'connect' | 'close', callback: Callback\<void\>): void
**示例:**
```
js
import
socket
from
'
@ohos.net.socket
'
;
let
tls
=
socket
.
constructTLSSocketInstance
();
tls
.
on
(
'
connect
'
,
()
=>
{
console
.
log
(
"
on connect success
"
)
...
...
@@ -3033,6 +3036,7 @@ off(type: 'connect' | 'close', callback?: Callback\<void\>): void
**示例:**
```
js
import
socket
from
'
@ohos.net.socket
'
;
let
tls
=
socket
.
constructTLSSocketInstance
();
let
callback1
=
()
=>
{
console
.
log
(
"
on connect success
"
);
...
...
@@ -3067,6 +3071,7 @@ on(type: 'error', callback: ErrorCallback): void
**示例:**
```
js
import
socket
from
'
@ohos.net.socket
'
;
let
tls
=
socket
.
constructTLSSocketInstance
();
tls
.
on
(
'
error
'
,
err
=>
{
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
))
...
...
@@ -3094,6 +3099,7 @@ off(type: 'error', callback?: ErrorCallback): void
**示例:**
```
js
import
socket
from
'
@ohos.net.socket
'
;
let
tls
=
socket
.
constructTLSSocketInstance
();
let
callback
=
err
=>
{
console
.
log
(
"
on error, err:
"
+
JSON
.
stringify
(
err
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录