161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit NetworkKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { AsyncCallback, Callback, ErrorCallback } from './@ohos.base';
2261847f8eSopenharmony_ciimport connection from "./@ohos.net.connection";
2361847f8eSopenharmony_ciimport type cert from './@ohos.security.cert';
2461847f8eSopenharmony_ci
2561847f8eSopenharmony_ci/**
2661847f8eSopenharmony_ci * Provides TCP and UDP Socket APIs.
2761847f8eSopenharmony_ci * @namespace socket
2861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack
2961847f8eSopenharmony_ci * @since 7
3061847f8eSopenharmony_ci */
3161847f8eSopenharmony_ci/**
3261847f8eSopenharmony_ci * Provides TCP and UDP Socket APIs.
3361847f8eSopenharmony_ci * @namespace socket
3461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.NetStack
3561847f8eSopenharmony_ci * @crossplatform
3661847f8eSopenharmony_ci * @since 10
3761847f8eSopenharmony_ci */
3861847f8eSopenharmony_cideclare namespace socket {
3961847f8eSopenharmony_ci  export import NetAddress = connection.NetAddress;
4061847f8eSopenharmony_ci  /**
4161847f8eSopenharmony_ci   * Deposit certificate
4261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
4361847f8eSopenharmony_ci   * @since 9
4461847f8eSopenharmony_ci   */
4561847f8eSopenharmony_ci  /**
4661847f8eSopenharmony_ci   * Deposit certificate
4761847f8eSopenharmony_ci   * @typedef { cert.EncodingBlob }
4861847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
4961847f8eSopenharmony_ci   * @crossplatform
5061847f8eSopenharmony_ci   * @since 10
5161847f8eSopenharmony_ci   */
5261847f8eSopenharmony_ci  export type X509CertRawData = cert.EncodingBlob;
5361847f8eSopenharmony_ci
5461847f8eSopenharmony_ci  /**
5561847f8eSopenharmony_ci   * Creates a UDPSocket object.
5661847f8eSopenharmony_ci   * @returns { UDPSocket } the UDPSocket of the constructUDPSocketInstance.
5761847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
5861847f8eSopenharmony_ci   * @since 7
5961847f8eSopenharmony_ci   */
6061847f8eSopenharmony_ci  /**
6161847f8eSopenharmony_ci   * Creates a UDPSocket object.
6261847f8eSopenharmony_ci   * @returns { UDPSocket } the UDPSocket of the constructUDPSocketInstance.
6361847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
6461847f8eSopenharmony_ci   * @crossplatform
6561847f8eSopenharmony_ci   * @since 10
6661847f8eSopenharmony_ci   */
6761847f8eSopenharmony_ci  function constructUDPSocketInstance(): UDPSocket;
6861847f8eSopenharmony_ci
6961847f8eSopenharmony_ci  /**
7061847f8eSopenharmony_ci   * Creates a MulticastSocket object.
7161847f8eSopenharmony_ci   * @returns { MulticastSocket } the MulticastSocket of the constructMulticastSocketInstance.
7261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
7361847f8eSopenharmony_ci   * @since 11
7461847f8eSopenharmony_ci   */
7561847f8eSopenharmony_ci  /**
7661847f8eSopenharmony_ci   * Creates a MulticastSocket object.
7761847f8eSopenharmony_ci   * @returns { MulticastSocket } the MulticastSocket of the constructMulticastSocketInstance.
7861847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
7961847f8eSopenharmony_ci   * @crossplatform
8061847f8eSopenharmony_ci   * @since 12
8161847f8eSopenharmony_ci   */
8261847f8eSopenharmony_ci  function constructMulticastSocketInstance(): MulticastSocket;
8361847f8eSopenharmony_ci
8461847f8eSopenharmony_ci  /**
8561847f8eSopenharmony_ci   * Creates a TCPSocket object.
8661847f8eSopenharmony_ci   * @returns { TCPSocket } the TCPSocket of the constructTCPSocketInstance.
8761847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
8861847f8eSopenharmony_ci   * @since 7
8961847f8eSopenharmony_ci   */
9061847f8eSopenharmony_ci  /**
9161847f8eSopenharmony_ci   * Creates a TCPSocket object.
9261847f8eSopenharmony_ci   * @returns { TCPSocket } the TCPSocket of the constructTCPSocketInstance.
9361847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
9461847f8eSopenharmony_ci   * @crossplatform
9561847f8eSopenharmony_ci   * @since 10
9661847f8eSopenharmony_ci   */
9761847f8eSopenharmony_ci  function constructTCPSocketInstance(): TCPSocket;
9861847f8eSopenharmony_ci
9961847f8eSopenharmony_ci  /**
10061847f8eSopenharmony_ci   * Creates a TLSSocket object.
10161847f8eSopenharmony_ci   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
10261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
10361847f8eSopenharmony_ci   * @since 9
10461847f8eSopenharmony_ci   */
10561847f8eSopenharmony_ci  /**
10661847f8eSopenharmony_ci   * Creates a TLSSocket object.
10761847f8eSopenharmony_ci   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
10861847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
10961847f8eSopenharmony_ci   * @crossplatform
11061847f8eSopenharmony_ci   * @since 10
11161847f8eSopenharmony_ci   */
11261847f8eSopenharmony_ci  function constructTLSSocketInstance(): TLSSocket;
11361847f8eSopenharmony_ci
11461847f8eSopenharmony_ci  /**
11561847f8eSopenharmony_ci   * Creates a TLSSocket object with a TCPSocket object.
11661847f8eSopenharmony_ci   * @param { TCPSocket } tcpSocket - Parameter for creating a TLSSocket object.
11761847f8eSopenharmony_ci   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
11861847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error.
11961847f8eSopenharmony_ci   * @throws { BusinessError } 2300002 - System internal error.
12061847f8eSopenharmony_ci   * @throws { BusinessError } 2303601 - Invalid socket FD.
12161847f8eSopenharmony_ci   * @throws { BusinessError } 2303602 - Socket is not connected.
12261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
12361847f8eSopenharmony_ci   * @since 12
12461847f8eSopenharmony_ci   */
12561847f8eSopenharmony_ci  function constructTLSSocketInstance(tcpSocket: TCPSocket): TLSSocket;
12661847f8eSopenharmony_ci
12761847f8eSopenharmony_ci  /**
12861847f8eSopenharmony_ci   * Creates a TCPSocketServer object.
12961847f8eSopenharmony_ci   * @returns { TCPSocketServer } the TCPSocketServer of the constructTCPSocketServerInstance.
13061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
13161847f8eSopenharmony_ci   * @since 10
13261847f8eSopenharmony_ci   */
13361847f8eSopenharmony_ci  function constructTCPSocketServerInstance(): TCPSocketServer;
13461847f8eSopenharmony_ci
13561847f8eSopenharmony_ci  /**
13661847f8eSopenharmony_ci   * Creates a TLSSocketServer object.
13761847f8eSopenharmony_ci   * @returns { TLSSocketServer } the TLSSocketServer of the constructTLSSocketServerInstance.
13861847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
13961847f8eSopenharmony_ci   * @since 10
14061847f8eSopenharmony_ci   */
14161847f8eSopenharmony_ci  function constructTLSSocketServerInstance(): TLSSocketServer;
14261847f8eSopenharmony_ci
14361847f8eSopenharmony_ci  /**
14461847f8eSopenharmony_ci   * Creates a LocalSocket object.
14561847f8eSopenharmony_ci   * @returns { LocalSocket } the LocalSocket of the constructLocalSocketInstance.
14661847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
14761847f8eSopenharmony_ci   * @since 11
14861847f8eSopenharmony_ci   */
14961847f8eSopenharmony_ci  /**
15061847f8eSopenharmony_ci   * Creates a LocalSocket object.
15161847f8eSopenharmony_ci   * @returns { LocalSocket } the LocalSocket of the constructLocalSocketInstance.
15261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
15361847f8eSopenharmony_ci   * @crossplatform
15461847f8eSopenharmony_ci   * @since 12
15561847f8eSopenharmony_ci   */
15661847f8eSopenharmony_ci  function constructLocalSocketInstance(): LocalSocket;
15761847f8eSopenharmony_ci
15861847f8eSopenharmony_ci  /**
15961847f8eSopenharmony_ci   * Creates a LocalSocketServer object.
16061847f8eSopenharmony_ci   * @returns { LocalSocketServer } the LocalSocketServer of the constructLocalSocketServerInstance.
16161847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
16261847f8eSopenharmony_ci   * @since 11
16361847f8eSopenharmony_ci   */
16461847f8eSopenharmony_ci  /**
16561847f8eSopenharmony_ci   * Creates a LocalSocketServer object.
16661847f8eSopenharmony_ci   * @returns { LocalSocketServer } the LocalSocketServer of the constructLocalSocketServerInstance.
16761847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
16861847f8eSopenharmony_ci   * @crossplatform
16961847f8eSopenharmony_ci   * @since 12
17061847f8eSopenharmony_ci   */
17161847f8eSopenharmony_ci  function constructLocalSocketServerInstance(): LocalSocketServer;
17261847f8eSopenharmony_ci
17361847f8eSopenharmony_ci  /**
17461847f8eSopenharmony_ci   * Defines the parameters for sending data over the UDPSocket connection.
17561847f8eSopenharmony_ci   * @interface UDPSendOptions
17661847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
17761847f8eSopenharmony_ci   * @since 7
17861847f8eSopenharmony_ci   */
17961847f8eSopenharmony_ci  /**
18061847f8eSopenharmony_ci   * Defines the parameters for sending data over the UDPSocket connection.
18161847f8eSopenharmony_ci   * @interface UDPSendOptions
18261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
18361847f8eSopenharmony_ci   * @crossplatform
18461847f8eSopenharmony_ci   * @since 10
18561847f8eSopenharmony_ci   */
18661847f8eSopenharmony_ci  export interface UDPSendOptions {
18761847f8eSopenharmony_ci    /**
18861847f8eSopenharmony_ci     * Data to send.
18961847f8eSopenharmony_ci     * @type {string | ArrayBuffer}
19061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19161847f8eSopenharmony_ci     * @since 7
19261847f8eSopenharmony_ci     */
19361847f8eSopenharmony_ci    /**
19461847f8eSopenharmony_ci     * Data to send.
19561847f8eSopenharmony_ci     * @type {string | ArrayBuffer}
19661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19761847f8eSopenharmony_ci     * @crossplatform
19861847f8eSopenharmony_ci     * @since 10
19961847f8eSopenharmony_ci     */
20061847f8eSopenharmony_ci    data: string | ArrayBuffer;
20161847f8eSopenharmony_ci
20261847f8eSopenharmony_ci    /**
20361847f8eSopenharmony_ci     * Destination address.
20461847f8eSopenharmony_ci     * @type {NetAddress}
20561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20661847f8eSopenharmony_ci     * @since 7
20761847f8eSopenharmony_ci     */
20861847f8eSopenharmony_ci    /**
20961847f8eSopenharmony_ci     * Destination address.
21061847f8eSopenharmony_ci     * @type {NetAddress}
21161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21261847f8eSopenharmony_ci     * @crossplatform
21361847f8eSopenharmony_ci     * @since 10
21461847f8eSopenharmony_ci     */
21561847f8eSopenharmony_ci    address: NetAddress;
21661847f8eSopenharmony_ci  }
21761847f8eSopenharmony_ci
21861847f8eSopenharmony_ci  /**
21961847f8eSopenharmony_ci   * @interface ExtraOptionsBase
22061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
22161847f8eSopenharmony_ci   * @since 7
22261847f8eSopenharmony_ci   */
22361847f8eSopenharmony_ci  /**
22461847f8eSopenharmony_ci   * @interface ExtraOptionsBase
22561847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
22661847f8eSopenharmony_ci   * @crossplatform
22761847f8eSopenharmony_ci   * @since 10
22861847f8eSopenharmony_ci   */
22961847f8eSopenharmony_ci  export interface ExtraOptionsBase {
23061847f8eSopenharmony_ci    /**
23161847f8eSopenharmony_ci     * Size of the receive buffer, in MBS.
23261847f8eSopenharmony_ci     * @type {?number}
23361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23461847f8eSopenharmony_ci     * @since 7
23561847f8eSopenharmony_ci     */
23661847f8eSopenharmony_ci    /**
23761847f8eSopenharmony_ci     * Size of the receive buffer, in MBS.
23861847f8eSopenharmony_ci     * @type {?number}
23961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24061847f8eSopenharmony_ci     * @crossplatform
24161847f8eSopenharmony_ci     * @since 10
24261847f8eSopenharmony_ci     */
24361847f8eSopenharmony_ci    receiveBufferSize?: number;
24461847f8eSopenharmony_ci
24561847f8eSopenharmony_ci    /**
24661847f8eSopenharmony_ci     * Size of the send buffer, in MBS.
24761847f8eSopenharmony_ci     * @type {?number}
24861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24961847f8eSopenharmony_ci     * @since 7
25061847f8eSopenharmony_ci     */
25161847f8eSopenharmony_ci    /**
25261847f8eSopenharmony_ci     * Size of the send buffer, in MBS.
25361847f8eSopenharmony_ci     * @type {?number}
25461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25561847f8eSopenharmony_ci     * @crossplatform
25661847f8eSopenharmony_ci     * @since 10
25761847f8eSopenharmony_ci     */
25861847f8eSopenharmony_ci    sendBufferSize?: number;
25961847f8eSopenharmony_ci
26061847f8eSopenharmony_ci    /**
26161847f8eSopenharmony_ci     * Whether to reuse addresses. The default value is false.
26261847f8eSopenharmony_ci     * @type {?boolean}
26361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26461847f8eSopenharmony_ci     * @since 7
26561847f8eSopenharmony_ci     */
26661847f8eSopenharmony_ci    /**
26761847f8eSopenharmony_ci     * Whether to reuse addresses. The default value is false.
26861847f8eSopenharmony_ci     * @type {?boolean}
26961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27061847f8eSopenharmony_ci     * @crossplatform
27161847f8eSopenharmony_ci     * @since 10
27261847f8eSopenharmony_ci     */
27361847f8eSopenharmony_ci    reuseAddress?: boolean;
27461847f8eSopenharmony_ci
27561847f8eSopenharmony_ci    /**
27661847f8eSopenharmony_ci     * Timeout duration of the UDPSocket connection, in milliseconds.
27761847f8eSopenharmony_ci     * @type {?number}
27861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27961847f8eSopenharmony_ci     * @since 7
28061847f8eSopenharmony_ci     */
28161847f8eSopenharmony_ci    /**
28261847f8eSopenharmony_ci     * Timeout duration of the UDPSocket connection, in milliseconds.
28361847f8eSopenharmony_ci     * @type {?number}
28461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28561847f8eSopenharmony_ci     * @crossplatform
28661847f8eSopenharmony_ci     * @since 10
28761847f8eSopenharmony_ci     */
28861847f8eSopenharmony_ci    socketTimeout?: number;
28961847f8eSopenharmony_ci  }
29061847f8eSopenharmony_ci
29161847f8eSopenharmony_ci  /**
29261847f8eSopenharmony_ci   * Defines other properties of the UDPSocket connection.
29361847f8eSopenharmony_ci   * @interface UDPExtraOptions
29461847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
29561847f8eSopenharmony_ci   * @since 7
29661847f8eSopenharmony_ci   */
29761847f8eSopenharmony_ci  /**
29861847f8eSopenharmony_ci   * Defines other properties of the UDPSocket connection.
29961847f8eSopenharmony_ci   * @interface UDPExtraOptions
30061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
30161847f8eSopenharmony_ci   * @crossplatform
30261847f8eSopenharmony_ci   * @since 10
30361847f8eSopenharmony_ci   */
30461847f8eSopenharmony_ci  export interface UDPExtraOptions extends ExtraOptionsBase {
30561847f8eSopenharmony_ci    /**
30661847f8eSopenharmony_ci     * Whether to send broadcast messages. The default value is false.
30761847f8eSopenharmony_ci     * @type {?boolean}
30861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30961847f8eSopenharmony_ci     * @since 7
31061847f8eSopenharmony_ci     */
31161847f8eSopenharmony_ci    /**
31261847f8eSopenharmony_ci     * Whether to send broadcast messages. The default value is false.
31361847f8eSopenharmony_ci     * @type {?boolean}
31461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31561847f8eSopenharmony_ci     * @crossplatform
31661847f8eSopenharmony_ci     * @since 10
31761847f8eSopenharmony_ci     */
31861847f8eSopenharmony_ci    broadcast?: boolean;
31961847f8eSopenharmony_ci  }
32061847f8eSopenharmony_ci
32161847f8eSopenharmony_ci  /**
32261847f8eSopenharmony_ci   * Defines the status of the socket connection.
32361847f8eSopenharmony_ci   * @interface SocketStateBase
32461847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
32561847f8eSopenharmony_ci   * @since 7
32661847f8eSopenharmony_ci   */
32761847f8eSopenharmony_ci  /**
32861847f8eSopenharmony_ci   * Defines the status of the socket connection.
32961847f8eSopenharmony_ci   * @interface SocketStateBase
33061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
33161847f8eSopenharmony_ci   * @crossplatform
33261847f8eSopenharmony_ci   * @since 10
33361847f8eSopenharmony_ci   */
33461847f8eSopenharmony_ci  export interface SocketStateBase {
33561847f8eSopenharmony_ci    /**
33661847f8eSopenharmony_ci     * Whether the connection is in the bound state.
33761847f8eSopenharmony_ci     * @type {boolean}
33861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
33961847f8eSopenharmony_ci     * @since 7
34061847f8eSopenharmony_ci     */
34161847f8eSopenharmony_ci    /**
34261847f8eSopenharmony_ci     * Whether the connection is in the bound state.
34361847f8eSopenharmony_ci     * @type {boolean}
34461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34561847f8eSopenharmony_ci     * @crossplatform
34661847f8eSopenharmony_ci     * @since 10
34761847f8eSopenharmony_ci     */
34861847f8eSopenharmony_ci    isBound: boolean;
34961847f8eSopenharmony_ci
35061847f8eSopenharmony_ci    /**
35161847f8eSopenharmony_ci     * Whether the connection is in the closed state.
35261847f8eSopenharmony_ci     * @type {boolean}
35361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35461847f8eSopenharmony_ci     * @since 7
35561847f8eSopenharmony_ci     */
35661847f8eSopenharmony_ci    /**
35761847f8eSopenharmony_ci     * Whether the connection is in the closed state.
35861847f8eSopenharmony_ci     * @type {boolean}
35961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36061847f8eSopenharmony_ci     * @crossplatform
36161847f8eSopenharmony_ci     * @since 10
36261847f8eSopenharmony_ci     */
36361847f8eSopenharmony_ci    isClose: boolean;
36461847f8eSopenharmony_ci
36561847f8eSopenharmony_ci    /**
36661847f8eSopenharmony_ci     * Whether the connection is in the connected state.
36761847f8eSopenharmony_ci     * @type {boolean}
36861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36961847f8eSopenharmony_ci     * @since 7
37061847f8eSopenharmony_ci     */
37161847f8eSopenharmony_ci    /**
37261847f8eSopenharmony_ci     * Whether the connection is in the connected state.
37361847f8eSopenharmony_ci     * @type {boolean}
37461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37561847f8eSopenharmony_ci     * @crossplatform
37661847f8eSopenharmony_ci     * @since 10
37761847f8eSopenharmony_ci     */
37861847f8eSopenharmony_ci    isConnected: boolean;
37961847f8eSopenharmony_ci  }
38061847f8eSopenharmony_ci
38161847f8eSopenharmony_ci  /**
38261847f8eSopenharmony_ci   * Defines information about the socket connection.
38361847f8eSopenharmony_ci   * @interface SocketRemoteInfo
38461847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
38561847f8eSopenharmony_ci   * @since 7
38661847f8eSopenharmony_ci   */
38761847f8eSopenharmony_ci  /**
38861847f8eSopenharmony_ci   * Defines information about the socket connection.
38961847f8eSopenharmony_ci   * @interface SocketRemoteInfo
39061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
39161847f8eSopenharmony_ci   * @crossplatform
39261847f8eSopenharmony_ci   * @since 10
39361847f8eSopenharmony_ci   */
39461847f8eSopenharmony_ci  export interface SocketRemoteInfo {
39561847f8eSopenharmony_ci    /**
39661847f8eSopenharmony_ci     * Bound IP address.
39761847f8eSopenharmony_ci     * @type {string}
39861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
39961847f8eSopenharmony_ci     * @since 7
40061847f8eSopenharmony_ci     */
40161847f8eSopenharmony_ci    /**
40261847f8eSopenharmony_ci     * Bound IP address.
40361847f8eSopenharmony_ci     * @type {string}
40461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40561847f8eSopenharmony_ci     * @crossplatform
40661847f8eSopenharmony_ci     * @since 10
40761847f8eSopenharmony_ci     */
40861847f8eSopenharmony_ci    address: string;
40961847f8eSopenharmony_ci
41061847f8eSopenharmony_ci    /**
41161847f8eSopenharmony_ci     * Network protocol type. The options are as follows: IPv4, IPv6.
41261847f8eSopenharmony_ci     * @type {'IPv4' | 'IPv6'}
41361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41461847f8eSopenharmony_ci     * @since 7
41561847f8eSopenharmony_ci     */
41661847f8eSopenharmony_ci    /**
41761847f8eSopenharmony_ci     * Network protocol type. The options are as follows: IPv4, IPv6.
41861847f8eSopenharmony_ci     * @type {'IPv4' | 'IPv6'}
41961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42061847f8eSopenharmony_ci     * @crossplatform
42161847f8eSopenharmony_ci     * @since 10
42261847f8eSopenharmony_ci     */
42361847f8eSopenharmony_ci    family: 'IPv4' | 'IPv6';
42461847f8eSopenharmony_ci
42561847f8eSopenharmony_ci    /**
42661847f8eSopenharmony_ci     * Port number. The value ranges from 0 to 65535.
42761847f8eSopenharmony_ci     * @type {number}
42861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42961847f8eSopenharmony_ci     * @since 7
43061847f8eSopenharmony_ci     */
43161847f8eSopenharmony_ci    /**
43261847f8eSopenharmony_ci     * Port number. The value ranges from 0 to 65535.
43361847f8eSopenharmony_ci     * @type {number}
43461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
43561847f8eSopenharmony_ci     * @crossplatform
43661847f8eSopenharmony_ci     * @since 10
43761847f8eSopenharmony_ci     */
43861847f8eSopenharmony_ci    port: number;
43961847f8eSopenharmony_ci
44061847f8eSopenharmony_ci    /**
44161847f8eSopenharmony_ci     * Length of the server response message, in bytes.
44261847f8eSopenharmony_ci     * @type {number}
44361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44461847f8eSopenharmony_ci     * @since 7
44561847f8eSopenharmony_ci     */
44661847f8eSopenharmony_ci    /**
44761847f8eSopenharmony_ci     * Length of the server response message, in bytes.
44861847f8eSopenharmony_ci     * @type {number}
44961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
45061847f8eSopenharmony_ci     * @crossplatform
45161847f8eSopenharmony_ci     * @since 10
45261847f8eSopenharmony_ci     */
45361847f8eSopenharmony_ci    size: number;
45461847f8eSopenharmony_ci  }
45561847f8eSopenharmony_ci
45661847f8eSopenharmony_ci  /**
45761847f8eSopenharmony_ci   * Defines the local socket connection information.
45861847f8eSopenharmony_ci   * @interface LocalSocketMessageInfo
45961847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
46061847f8eSopenharmony_ci   * @since 11
46161847f8eSopenharmony_ci   */
46261847f8eSopenharmony_ci  /**
46361847f8eSopenharmony_ci   * Defines the local socket connection information.
46461847f8eSopenharmony_ci   * @interface LocalSocketMessageInfo
46561847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
46661847f8eSopenharmony_ci   * @crossplatform
46761847f8eSopenharmony_ci   * @since 12
46861847f8eSopenharmony_ci   */
46961847f8eSopenharmony_ci  export interface LocalSocketMessageInfo {
47061847f8eSopenharmony_ci    /**
47161847f8eSopenharmony_ci     * Message data.
47261847f8eSopenharmony_ci     * @type {ArrayBuffer}
47361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
47461847f8eSopenharmony_ci     * @since 11
47561847f8eSopenharmony_ci     */
47661847f8eSopenharmony_ci    /**
47761847f8eSopenharmony_ci     * Message data.
47861847f8eSopenharmony_ci     * @type {ArrayBuffer}
47961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
48061847f8eSopenharmony_ci     * @crossplatform
48161847f8eSopenharmony_ci     * @since 12
48261847f8eSopenharmony_ci     */
48361847f8eSopenharmony_ci    message: ArrayBuffer;
48461847f8eSopenharmony_ci
48561847f8eSopenharmony_ci    /**
48661847f8eSopenharmony_ci     * Bound local socket address.
48761847f8eSopenharmony_ci     * @type {string}
48861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
48961847f8eSopenharmony_ci     * @since 11
49061847f8eSopenharmony_ci     */
49161847f8eSopenharmony_ci    /**
49261847f8eSopenharmony_ci     * Bound local socket address.
49361847f8eSopenharmony_ci     * @type {string}
49461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
49561847f8eSopenharmony_ci     * @crossplatform
49661847f8eSopenharmony_ci     * @since 12
49761847f8eSopenharmony_ci     */
49861847f8eSopenharmony_ci    address: string;
49961847f8eSopenharmony_ci
50061847f8eSopenharmony_ci    /**
50161847f8eSopenharmony_ci     * Length of the message, in bytes.
50261847f8eSopenharmony_ci     * @type {number}
50361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
50461847f8eSopenharmony_ci     * @since 11
50561847f8eSopenharmony_ci     */
50661847f8eSopenharmony_ci    /**
50761847f8eSopenharmony_ci     * Length of the message, in bytes.
50861847f8eSopenharmony_ci     * @type {number}
50961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
51061847f8eSopenharmony_ci     * @crossplatform
51161847f8eSopenharmony_ci     * @since 12
51261847f8eSopenharmony_ci     */
51361847f8eSopenharmony_ci    size: number;
51461847f8eSopenharmony_ci  }
51561847f8eSopenharmony_ci
51661847f8eSopenharmony_ci  /**
51761847f8eSopenharmony_ci   * Defines a local address.
51861847f8eSopenharmony_ci   * @interface LocalAddress
51961847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
52061847f8eSopenharmony_ci   * @since 11
52161847f8eSopenharmony_ci   */
52261847f8eSopenharmony_ci  /**
52361847f8eSopenharmony_ci   * Defines a local address.
52461847f8eSopenharmony_ci   * @interface LocalAddress
52561847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
52661847f8eSopenharmony_ci   * @crossplatform
52761847f8eSopenharmony_ci   * @since 12
52861847f8eSopenharmony_ci   */
52961847f8eSopenharmony_ci  export interface LocalAddress {
53061847f8eSopenharmony_ci    /**
53161847f8eSopenharmony_ci     * LocalAddress address.
53261847f8eSopenharmony_ci     * @type {string}
53361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
53461847f8eSopenharmony_ci     * @since 11
53561847f8eSopenharmony_ci     */
53661847f8eSopenharmony_ci    /**
53761847f8eSopenharmony_ci     * LocalAddress address.
53861847f8eSopenharmony_ci     * @type {string}
53961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
54061847f8eSopenharmony_ci     * @crossplatform
54161847f8eSopenharmony_ci     * @since 12
54261847f8eSopenharmony_ci     */
54361847f8eSopenharmony_ci    address: string;
54461847f8eSopenharmony_ci  }
54561847f8eSopenharmony_ci
54661847f8eSopenharmony_ci  /**
54761847f8eSopenharmony_ci   * Defines LocalSocket connection parameters.
54861847f8eSopenharmony_ci   * @interface LocalConnectOptions
54961847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
55061847f8eSopenharmony_ci   * @since 11
55161847f8eSopenharmony_ci   */
55261847f8eSopenharmony_ci  /**
55361847f8eSopenharmony_ci   * Defines LocalSocket connection parameters.
55461847f8eSopenharmony_ci   * @interface LocalConnectOptions
55561847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
55661847f8eSopenharmony_ci   * @crossplatform
55761847f8eSopenharmony_ci   * @since 12
55861847f8eSopenharmony_ci   */
55961847f8eSopenharmony_ci  export interface LocalConnectOptions {
56061847f8eSopenharmony_ci    /**
56161847f8eSopenharmony_ci     * Bound Local address.
56261847f8eSopenharmony_ci     * @type {LocalAddress}
56361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
56461847f8eSopenharmony_ci     * @since 11
56561847f8eSopenharmony_ci     */
56661847f8eSopenharmony_ci    /**
56761847f8eSopenharmony_ci     * Bound Local address.
56861847f8eSopenharmony_ci     * @type {LocalAddress}
56961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
57061847f8eSopenharmony_ci     * @crossplatform
57161847f8eSopenharmony_ci     * @since 12
57261847f8eSopenharmony_ci     */
57361847f8eSopenharmony_ci    address: LocalAddress;
57461847f8eSopenharmony_ci
57561847f8eSopenharmony_ci    /**
57661847f8eSopenharmony_ci     * Timeout duration of the LocalSocket connection, in milliseconds.
57761847f8eSopenharmony_ci     * @type {?number}
57861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
57961847f8eSopenharmony_ci     * @since 11
58061847f8eSopenharmony_ci     */
58161847f8eSopenharmony_ci    /**
58261847f8eSopenharmony_ci     * Timeout duration of the LocalSocket connection, in milliseconds.
58361847f8eSopenharmony_ci     * @type {?number}
58461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
58561847f8eSopenharmony_ci     * @crossplatform
58661847f8eSopenharmony_ci     * @since 12
58761847f8eSopenharmony_ci     */
58861847f8eSopenharmony_ci    timeout?: number;
58961847f8eSopenharmony_ci  }
59061847f8eSopenharmony_ci
59161847f8eSopenharmony_ci  /**
59261847f8eSopenharmony_ci   * Defines the parameters for sending data over the LocalSocket connection.
59361847f8eSopenharmony_ci   * @interface LocalSendOptions
59461847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
59561847f8eSopenharmony_ci   * @since 11
59661847f8eSopenharmony_ci   */
59761847f8eSopenharmony_ci  /**
59861847f8eSopenharmony_ci   * Defines the parameters for sending data over the LocalSocket connection.
59961847f8eSopenharmony_ci   * @interface LocalSendOptions
60061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
60161847f8eSopenharmony_ci   * @crossplatform
60261847f8eSopenharmony_ci   * @since 12
60361847f8eSopenharmony_ci   */
60461847f8eSopenharmony_ci  export interface LocalSendOptions {
60561847f8eSopenharmony_ci    /**
60661847f8eSopenharmony_ci     * Data to send.
60761847f8eSopenharmony_ci     * @type {string | ArrayBuffer}
60861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
60961847f8eSopenharmony_ci     * @since 11
61061847f8eSopenharmony_ci     */
61161847f8eSopenharmony_ci    /**
61261847f8eSopenharmony_ci     * Data to send.
61361847f8eSopenharmony_ci     * @type {string | ArrayBuffer}
61461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
61561847f8eSopenharmony_ci     * @crossplatform
61661847f8eSopenharmony_ci     * @since 12
61761847f8eSopenharmony_ci     */
61861847f8eSopenharmony_ci    data: string | ArrayBuffer;
61961847f8eSopenharmony_ci
62061847f8eSopenharmony_ci    /**
62161847f8eSopenharmony_ci     * Character encoding format.
62261847f8eSopenharmony_ci     * @type {?string}
62361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
62461847f8eSopenharmony_ci     * @since 11
62561847f8eSopenharmony_ci     */
62661847f8eSopenharmony_ci    /**
62761847f8eSopenharmony_ci     * Character encoding format.
62861847f8eSopenharmony_ci     * @type {?string}
62961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
63061847f8eSopenharmony_ci     * @crossplatform
63161847f8eSopenharmony_ci     * @since 12
63261847f8eSopenharmony_ci     */
63361847f8eSopenharmony_ci    encoding?: string;
63461847f8eSopenharmony_ci  }
63561847f8eSopenharmony_ci
63661847f8eSopenharmony_ci  /**
63761847f8eSopenharmony_ci   * Defines a UDPSocket connection.
63861847f8eSopenharmony_ci   * @interface UDPSocket
63961847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
64061847f8eSopenharmony_ci   * @since 7
64161847f8eSopenharmony_ci   */
64261847f8eSopenharmony_ci  /**
64361847f8eSopenharmony_ci   * Defines a UDPSocket connection.
64461847f8eSopenharmony_ci   * @interface UDPSocket
64561847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
64661847f8eSopenharmony_ci   * @crossplatform
64761847f8eSopenharmony_ci   * @since 10
64861847f8eSopenharmony_ci   */
64961847f8eSopenharmony_ci  export interface UDPSocket {
65061847f8eSopenharmony_ci    /**
65161847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
65261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
65361847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
65461847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
65561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
65661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
65761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
65861847f8eSopenharmony_ci     * @since 7
65961847f8eSopenharmony_ci     */
66061847f8eSopenharmony_ci    /**
66161847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
66261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
66361847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
66461847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
66561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
66661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
66761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
66861847f8eSopenharmony_ci     * @crossplatform
66961847f8eSopenharmony_ci     * @since 10
67061847f8eSopenharmony_ci     */
67161847f8eSopenharmony_ci    bind(address: NetAddress, callback: AsyncCallback<void>): void;
67261847f8eSopenharmony_ci
67361847f8eSopenharmony_ci    /**
67461847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
67561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
67661847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
67761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
67861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
67961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
68061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
68161847f8eSopenharmony_ci     * @since 7
68261847f8eSopenharmony_ci     */
68361847f8eSopenharmony_ci    /**
68461847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
68561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
68661847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
68761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
68861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
68961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
69061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
69161847f8eSopenharmony_ci     * @crossplatform
69261847f8eSopenharmony_ci     * @since 10
69361847f8eSopenharmony_ci     */
69461847f8eSopenharmony_ci    bind(address: NetAddress): Promise<void>;
69561847f8eSopenharmony_ci
69661847f8eSopenharmony_ci    /**
69761847f8eSopenharmony_ci     * Obtains the local address of a UDPSocket connection.
69861847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
69961847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
70061847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
70161847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
70261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
70361847f8eSopenharmony_ci     * @since 12
70461847f8eSopenharmony_ci     */
70561847f8eSopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
70661847f8eSopenharmony_ci
70761847f8eSopenharmony_ci    /**
70861847f8eSopenharmony_ci     * Sends data over a UDPSocket connection.
70961847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
71061847f8eSopenharmony_ci     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
71161847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
71261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
71361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
71461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
71561847f8eSopenharmony_ci     * @since 7
71661847f8eSopenharmony_ci     */
71761847f8eSopenharmony_ci    /**
71861847f8eSopenharmony_ci     * Sends data over a UDPSocket connection.
71961847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
72061847f8eSopenharmony_ci     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
72161847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
72261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
72361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
72461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
72561847f8eSopenharmony_ci     * @crossplatform
72661847f8eSopenharmony_ci     * @since 10
72761847f8eSopenharmony_ci     */
72861847f8eSopenharmony_ci    send(options: UDPSendOptions, callback: AsyncCallback<void>): void;
72961847f8eSopenharmony_ci
73061847f8eSopenharmony_ci    /**
73161847f8eSopenharmony_ci     * Sends data over a UDPSocket connection.
73261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
73361847f8eSopenharmony_ci     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
73461847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
73561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
73661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
73761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
73861847f8eSopenharmony_ci     * @since 7
73961847f8eSopenharmony_ci     */
74061847f8eSopenharmony_ci    /**
74161847f8eSopenharmony_ci     * Sends data over a UDPSocket connection.
74261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
74361847f8eSopenharmony_ci     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
74461847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
74561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
74661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
74761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
74861847f8eSopenharmony_ci     * @crossplatform
74961847f8eSopenharmony_ci     * @since 10
75061847f8eSopenharmony_ci     */
75161847f8eSopenharmony_ci    send(options: UDPSendOptions): Promise<void>;
75261847f8eSopenharmony_ci
75361847f8eSopenharmony_ci    /**
75461847f8eSopenharmony_ci     * Closes a UDPSocket connection.
75561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
75661847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
75761847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
75861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
75961847f8eSopenharmony_ci     * @since 7
76061847f8eSopenharmony_ci     */
76161847f8eSopenharmony_ci    /**
76261847f8eSopenharmony_ci     * Closes a UDPSocket connection.
76361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
76461847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
76561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
76661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
76761847f8eSopenharmony_ci     * @crossplatform
76861847f8eSopenharmony_ci     * @since 10
76961847f8eSopenharmony_ci     */
77061847f8eSopenharmony_ci    close(callback: AsyncCallback<void>): void;
77161847f8eSopenharmony_ci
77261847f8eSopenharmony_ci    /**
77361847f8eSopenharmony_ci     * Closes a UDPSocket connection.
77461847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
77561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
77661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
77761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
77861847f8eSopenharmony_ci     * @since 7
77961847f8eSopenharmony_ci     */
78061847f8eSopenharmony_ci    /**
78161847f8eSopenharmony_ci     * Closes a UDPSocket connection.
78261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
78361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
78461847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
78561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
78661847f8eSopenharmony_ci     * @crossplatform
78761847f8eSopenharmony_ci     * @since 10
78861847f8eSopenharmony_ci     */
78961847f8eSopenharmony_ci    close(): Promise<void>;
79061847f8eSopenharmony_ci
79161847f8eSopenharmony_ci    /**
79261847f8eSopenharmony_ci     * Obtains the status of the UDPSocket connection.
79361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
79461847f8eSopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}.
79561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
79661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
79761847f8eSopenharmony_ci     * @since 7
79861847f8eSopenharmony_ci     */
79961847f8eSopenharmony_ci    /**
80061847f8eSopenharmony_ci     * Obtains the status of the UDPSocket connection.
80161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
80261847f8eSopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}.
80361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
80461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
80561847f8eSopenharmony_ci     * @crossplatform
80661847f8eSopenharmony_ci     * @since 10
80761847f8eSopenharmony_ci     */
80861847f8eSopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
80961847f8eSopenharmony_ci
81061847f8eSopenharmony_ci    /**
81161847f8eSopenharmony_ci     * Obtains the status of the UDPSocket connection.
81261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
81361847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
81461847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
81561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
81661847f8eSopenharmony_ci     * @since 7
81761847f8eSopenharmony_ci     */
81861847f8eSopenharmony_ci    /**
81961847f8eSopenharmony_ci     * Obtains the status of the UDPSocket connection.
82061847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
82161847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
82261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
82361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
82461847f8eSopenharmony_ci     * @crossplatform
82561847f8eSopenharmony_ci     * @since 10
82661847f8eSopenharmony_ci     */
82761847f8eSopenharmony_ci    getState(): Promise<SocketStateBase>;
82861847f8eSopenharmony_ci
82961847f8eSopenharmony_ci    /**
83061847f8eSopenharmony_ci     * Sets other attributes of the UDPSocket connection.
83161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
83261847f8eSopenharmony_ci     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
83361847f8eSopenharmony_ci     * @param { AsyncCallback<void> }callback - the callback of setExtraOptions.
83461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
83561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
83661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
83761847f8eSopenharmony_ci     * @since 7
83861847f8eSopenharmony_ci     */
83961847f8eSopenharmony_ci    /**
84061847f8eSopenharmony_ci     * Sets other attributes of the UDPSocket connection.
84161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
84261847f8eSopenharmony_ci     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
84361847f8eSopenharmony_ci     * @param { AsyncCallback<void> }callback - the callback of setExtraOptions.
84461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
84561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
84661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
84761847f8eSopenharmony_ci     * @crossplatform
84861847f8eSopenharmony_ci     * @since 10
84961847f8eSopenharmony_ci     */
85061847f8eSopenharmony_ci    setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback<void>): void;
85161847f8eSopenharmony_ci
85261847f8eSopenharmony_ci    /**
85361847f8eSopenharmony_ci     * Sets other attributes of the UDPSocket connection.
85461847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
85561847f8eSopenharmony_ci     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
85661847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
85761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
85861847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
85961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
86061847f8eSopenharmony_ci     * @since 7
86161847f8eSopenharmony_ci     */
86261847f8eSopenharmony_ci    /**
86361847f8eSopenharmony_ci     * Sets other attributes of the UDPSocket connection.
86461847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
86561847f8eSopenharmony_ci     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
86661847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
86761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
86861847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
86961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
87061847f8eSopenharmony_ci     * @crossplatform
87161847f8eSopenharmony_ci     * @since 10
87261847f8eSopenharmony_ci     */
87361847f8eSopenharmony_ci    setExtraOptions(options: UDPExtraOptions): Promise<void>;
87461847f8eSopenharmony_ci
87561847f8eSopenharmony_ci    /**
87661847f8eSopenharmony_ci     * Listens for message receiving events of the UDPSocket connection.
87761847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
87861847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
87961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
88061847f8eSopenharmony_ci     * @since 7
88161847f8eSopenharmony_ci     */
88261847f8eSopenharmony_ci    /**
88361847f8eSopenharmony_ci     * Listens for message receiving events of the UDPSocket connection.
88461847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
88561847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
88661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
88761847f8eSopenharmony_ci     * @crossplatform
88861847f8eSopenharmony_ci     * @since 10
88961847f8eSopenharmony_ci     */
89061847f8eSopenharmony_ci    /**
89161847f8eSopenharmony_ci     * Listens for message receiving events of the UDPSocket connection.
89261847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
89361847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
89461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
89561847f8eSopenharmony_ci     * @crossplatform
89661847f8eSopenharmony_ci     * @since 11
89761847f8eSopenharmony_ci     */
89861847f8eSopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
89961847f8eSopenharmony_ci
90061847f8eSopenharmony_ci    /**
90161847f8eSopenharmony_ci     * Cancels listening for message receiving events of the UDPSocket connection.
90261847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
90361847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
90461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
90561847f8eSopenharmony_ci     * @since 7
90661847f8eSopenharmony_ci     */
90761847f8eSopenharmony_ci    /**
90861847f8eSopenharmony_ci     * Cancels listening for message receiving events of the UDPSocket connection.
90961847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
91061847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
91161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
91261847f8eSopenharmony_ci     * @crossplatform
91361847f8eSopenharmony_ci     * @since 10
91461847f8eSopenharmony_ci     */
91561847f8eSopenharmony_ci    /**
91661847f8eSopenharmony_ci     * Cancels listening for message receiving events of the UDPSocket connection.
91761847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
91861847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
91961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
92061847f8eSopenharmony_ci     * @crossplatform
92161847f8eSopenharmony_ci     * @since 11
92261847f8eSopenharmony_ci     */
92361847f8eSopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
92461847f8eSopenharmony_ci
92561847f8eSopenharmony_ci    /**
92661847f8eSopenharmony_ci     * Listens for data packet message events or close events of the UDPSocket connection.
92761847f8eSopenharmony_ci     * @param { 'listening' | 'close' } type - Indicates Event name.
92861847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
92961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
93061847f8eSopenharmony_ci     * @since 7
93161847f8eSopenharmony_ci     */
93261847f8eSopenharmony_ci    /**
93361847f8eSopenharmony_ci     * Listens for data packet message events or close events of the UDPSocket connection.
93461847f8eSopenharmony_ci     * @param { 'listening' | 'close' } type - Indicates Event name.
93561847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
93661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
93761847f8eSopenharmony_ci     * @crossplatform
93861847f8eSopenharmony_ci     * @since 10
93961847f8eSopenharmony_ci     */
94061847f8eSopenharmony_ci    on(type: 'listening' | 'close', callback: Callback<void>): void;
94161847f8eSopenharmony_ci
94261847f8eSopenharmony_ci    /**
94361847f8eSopenharmony_ci     * Cancels listening for data packet message events or close events of the UDPSocket connection.
94461847f8eSopenharmony_ci     * @param { 'listening' | 'close' } type - Indicates Event name.
94561847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
94661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
94761847f8eSopenharmony_ci     * @since 7
94861847f8eSopenharmony_ci     */
94961847f8eSopenharmony_ci    /**
95061847f8eSopenharmony_ci     * Cancels listening for data packet message events or close events of the UDPSocket connection.
95161847f8eSopenharmony_ci     * @param { 'listening' | 'close' } type - Indicates Event name.
95261847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
95361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
95461847f8eSopenharmony_ci     * @crossplatform
95561847f8eSopenharmony_ci     * @since 10
95661847f8eSopenharmony_ci     */
95761847f8eSopenharmony_ci    off(type: 'listening' | 'close', callback?: Callback<void>): void;
95861847f8eSopenharmony_ci
95961847f8eSopenharmony_ci    /**
96061847f8eSopenharmony_ci     * Listens for error events of the UDPSocket connection.
96161847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
96261847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
96361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
96461847f8eSopenharmony_ci     * @since 7
96561847f8eSopenharmony_ci     */
96661847f8eSopenharmony_ci    /**
96761847f8eSopenharmony_ci     * Listens for error events of the UDPSocket connection.
96861847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
96961847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
97061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
97161847f8eSopenharmony_ci     * @crossplatform
97261847f8eSopenharmony_ci     * @since 10
97361847f8eSopenharmony_ci     */
97461847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
97561847f8eSopenharmony_ci
97661847f8eSopenharmony_ci    /**
97761847f8eSopenharmony_ci     * Cancels listening for error events of the UDPSocket connection.
97861847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
97961847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
98061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
98161847f8eSopenharmony_ci     * @since 7
98261847f8eSopenharmony_ci     */
98361847f8eSopenharmony_ci    /**
98461847f8eSopenharmony_ci     * Cancels listening for error events of the UDPSocket connection.
98561847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
98661847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
98761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
98861847f8eSopenharmony_ci     * @crossplatform
98961847f8eSopenharmony_ci     * @since 10
99061847f8eSopenharmony_ci     */
99161847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
99261847f8eSopenharmony_ci  }
99361847f8eSopenharmony_ci
99461847f8eSopenharmony_ci  /**
99561847f8eSopenharmony_ci   * Defines a UDP MulticastSocket connection.
99661847f8eSopenharmony_ci   * @interface MulticastSocket
99761847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
99861847f8eSopenharmony_ci   * @since 11
99961847f8eSopenharmony_ci   */
100061847f8eSopenharmony_ci  /**
100161847f8eSopenharmony_ci   * Defines a UDP MulticastSocket connection.
100261847f8eSopenharmony_ci   * @interface MulticastSocket
100361847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
100461847f8eSopenharmony_ci   * @crossplatform
100561847f8eSopenharmony_ci   * @since 12
100661847f8eSopenharmony_ci   */
100761847f8eSopenharmony_ci  export interface MulticastSocket extends UDPSocket {
100861847f8eSopenharmony_ci    /**
100961847f8eSopenharmony_ci     * Add the socket to the multicast group.
101061847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
101161847f8eSopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
101261847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of addMembership.
101361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
101461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
101561847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
101661847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
101761847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
101861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
101961847f8eSopenharmony_ci     * @since 11
102061847f8eSopenharmony_ci     */
102161847f8eSopenharmony_ci    /**
102261847f8eSopenharmony_ci     * Add the socket to the multicast group.
102361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
102461847f8eSopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
102561847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of addMembership.
102661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
102761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
102861847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
102961847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
103061847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
103161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
103261847f8eSopenharmony_ci     * @crossplatform
103361847f8eSopenharmony_ci     * @since 12
103461847f8eSopenharmony_ci     */
103561847f8eSopenharmony_ci    addMembership(multicastAddress: NetAddress, callback: AsyncCallback<void>): void;
103661847f8eSopenharmony_ci
103761847f8eSopenharmony_ci    /**
103861847f8eSopenharmony_ci     * Add the socket to the multicast group.
103961847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
104061847f8eSopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
104161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
104261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
104361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
104461847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
104561847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
104661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
104761847f8eSopenharmony_ci     * @since 11
104861847f8eSopenharmony_ci     */
104961847f8eSopenharmony_ci    /**
105061847f8eSopenharmony_ci     * Add the socket to the multicast group.
105161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
105261847f8eSopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
105361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
105461847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
105561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
105661847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
105761847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
105861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
105961847f8eSopenharmony_ci     * @crossplatform
106061847f8eSopenharmony_ci     * @since 12
106161847f8eSopenharmony_ci     */
106261847f8eSopenharmony_ci    addMembership(multicastAddress: NetAddress): Promise<void>;
106361847f8eSopenharmony_ci
106461847f8eSopenharmony_ci    /**
106561847f8eSopenharmony_ci     * Drop the socket from the multicast group.
106661847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
106761847f8eSopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
106861847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of dropMembership.
106961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
107061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
107161847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
107261847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
107361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
107461847f8eSopenharmony_ci     * @since 11
107561847f8eSopenharmony_ci     */
107661847f8eSopenharmony_ci    /**
107761847f8eSopenharmony_ci     * Drop the socket from the multicast group.
107861847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
107961847f8eSopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
108061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of dropMembership.
108161847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
108261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
108361847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
108461847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
108561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
108661847f8eSopenharmony_ci     * @crossplatform
108761847f8eSopenharmony_ci     * @since 12
108861847f8eSopenharmony_ci     */
108961847f8eSopenharmony_ci    dropMembership(multicastAddress: NetAddress, callback: AsyncCallback<void>): void;
109061847f8eSopenharmony_ci
109161847f8eSopenharmony_ci    /**
109261847f8eSopenharmony_ci     * Drop the socket from the multicast group.
109361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
109461847f8eSopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
109561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
109661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
109761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
109861847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
109961847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
110061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
110161847f8eSopenharmony_ci     * @since 11
110261847f8eSopenharmony_ci     */
110361847f8eSopenharmony_ci    /**
110461847f8eSopenharmony_ci     * Drop the socket from the multicast group.
110561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
110661847f8eSopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
110761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
110861847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
110961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
111061847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
111161847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
111261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
111361847f8eSopenharmony_ci     * @crossplatform
111461847f8eSopenharmony_ci     * @since 12
111561847f8eSopenharmony_ci     */
111661847f8eSopenharmony_ci    dropMembership(multicastAddress: NetAddress): Promise<void>;
111761847f8eSopenharmony_ci
111861847f8eSopenharmony_ci    /**
111961847f8eSopenharmony_ci     * Set the TTL value for socket multicast packets.
112061847f8eSopenharmony_ci     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
112161847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setMulticastTTL.
112261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
112361847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
112461847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
112561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
112661847f8eSopenharmony_ci     * @since 11
112761847f8eSopenharmony_ci     */
112861847f8eSopenharmony_ci    /**
112961847f8eSopenharmony_ci     * Set the TTL value for socket multicast packets.
113061847f8eSopenharmony_ci     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
113161847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setMulticastTTL.
113261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
113361847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
113461847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
113561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
113661847f8eSopenharmony_ci     * @crossplatform
113761847f8eSopenharmony_ci     * @since 12
113861847f8eSopenharmony_ci     */
113961847f8eSopenharmony_ci    setMulticastTTL(ttl: number, callback: AsyncCallback<void>): void;
114061847f8eSopenharmony_ci
114161847f8eSopenharmony_ci    /**
114261847f8eSopenharmony_ci     * Set the TTL value for socket multicast packet.
114361847f8eSopenharmony_ci     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
114461847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
114561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
114661847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
114761847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
114861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
114961847f8eSopenharmony_ci     * @since 11
115061847f8eSopenharmony_ci     */
115161847f8eSopenharmony_ci    /**
115261847f8eSopenharmony_ci     * Set the TTL value for socket multicast packet.
115361847f8eSopenharmony_ci     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
115461847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
115561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
115661847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
115761847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
115861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
115961847f8eSopenharmony_ci     * @crossplatform
116061847f8eSopenharmony_ci     * @since 12
116161847f8eSopenharmony_ci     */
116261847f8eSopenharmony_ci    setMulticastTTL(ttl: number): Promise<void>;
116361847f8eSopenharmony_ci
116461847f8eSopenharmony_ci    /**
116561847f8eSopenharmony_ci     * Get the TTL value of socket multicast packet.
116661847f8eSopenharmony_ci     * @param { AsyncCallback<number> } callback - The callback of getMulticastTTL.
116761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
116861847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
116961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
117061847f8eSopenharmony_ci     * @since 11
117161847f8eSopenharmony_ci     */
117261847f8eSopenharmony_ci    /**
117361847f8eSopenharmony_ci     * Get the TTL value of socket multicast packet.
117461847f8eSopenharmony_ci     * @param { AsyncCallback<number> } callback - The callback of getMulticastTTL.
117561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
117661847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
117761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
117861847f8eSopenharmony_ci     * @crossplatform
117961847f8eSopenharmony_ci     * @since 12
118061847f8eSopenharmony_ci     */
118161847f8eSopenharmony_ci    getMulticastTTL(callback: AsyncCallback<number>): void;
118261847f8eSopenharmony_ci
118361847f8eSopenharmony_ci    /**
118461847f8eSopenharmony_ci     * Get the TTL value of socket multicast packet.
118561847f8eSopenharmony_ci     * @returns { Promise<number> } The promise returned by the function.
118661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
118761847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
118861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
118961847f8eSopenharmony_ci     * @since 11
119061847f8eSopenharmony_ci     */
119161847f8eSopenharmony_ci    /**
119261847f8eSopenharmony_ci     * Get the TTL value of socket multicast packet.
119361847f8eSopenharmony_ci     * @returns { Promise<number> } The promise returned by the function.
119461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
119561847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
119661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
119761847f8eSopenharmony_ci     * @crossplatform
119861847f8eSopenharmony_ci     * @since 12
119961847f8eSopenharmony_ci     */
120061847f8eSopenharmony_ci    getMulticastTTL(): Promise<number>;
120161847f8eSopenharmony_ci
120261847f8eSopenharmony_ci    /**
120361847f8eSopenharmony_ci     * Set the loopback mode for the socket.
120461847f8eSopenharmony_ci     * @param { boolean } flag - Whether to enable loopback mode.
120561847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setLoopbackMode.
120661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
120761847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
120861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
120961847f8eSopenharmony_ci     * @since 11
121061847f8eSopenharmony_ci     */
121161847f8eSopenharmony_ci    /**
121261847f8eSopenharmony_ci     * Set the loopback mode for the socket.
121361847f8eSopenharmony_ci     * @param { boolean } flag - Whether to enable loopback mode.
121461847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setLoopbackMode.
121561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
121661847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
121761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
121861847f8eSopenharmony_ci     * @crossplatform
121961847f8eSopenharmony_ci     * @since 12
122061847f8eSopenharmony_ci     */
122161847f8eSopenharmony_ci    setLoopbackMode(flag: boolean, callback: AsyncCallback<void>): void;
122261847f8eSopenharmony_ci
122361847f8eSopenharmony_ci    /**
122461847f8eSopenharmony_ci     * Set the loopback mode for the socket.
122561847f8eSopenharmony_ci     * @param { boolean } flag - Whether to enable loopback mode.
122661847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
122761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
122861847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
122961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
123061847f8eSopenharmony_ci     * @since 11
123161847f8eSopenharmony_ci     */
123261847f8eSopenharmony_ci    /**
123361847f8eSopenharmony_ci     * Set the loopback mode for the socket.
123461847f8eSopenharmony_ci     * @param { boolean } flag - Whether to enable loopback mode.
123561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
123661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
123761847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
123861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
123961847f8eSopenharmony_ci     * @crossplatform
124061847f8eSopenharmony_ci     * @since 12
124161847f8eSopenharmony_ci     */
124261847f8eSopenharmony_ci    setLoopbackMode(flag: boolean): Promise<void>;
124361847f8eSopenharmony_ci
124461847f8eSopenharmony_ci    /**
124561847f8eSopenharmony_ci     * Get the loopback mode of the socket.
124661847f8eSopenharmony_ci     * @param { AsyncCallback<boolean> } callback - The callback of getLoopbackMode.
124761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
124861847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
124961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
125061847f8eSopenharmony_ci     * @since 11
125161847f8eSopenharmony_ci     */
125261847f8eSopenharmony_ci    /**
125361847f8eSopenharmony_ci     * Get the loopback mode of the socket.
125461847f8eSopenharmony_ci     * @param { AsyncCallback<boolean> } callback - The callback of getLoopbackMode.
125561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
125661847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
125761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
125861847f8eSopenharmony_ci     * @crossplatform
125961847f8eSopenharmony_ci     * @since 12
126061847f8eSopenharmony_ci     */
126161847f8eSopenharmony_ci    getLoopbackMode(callback: AsyncCallback<boolean>): void;
126261847f8eSopenharmony_ci
126361847f8eSopenharmony_ci    /**
126461847f8eSopenharmony_ci     * Get the loopback mode of the socket.
126561847f8eSopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
126661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
126761847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
126861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
126961847f8eSopenharmony_ci     * @since 11
127061847f8eSopenharmony_ci     */
127161847f8eSopenharmony_ci    /**
127261847f8eSopenharmony_ci     * Get the loopback mode of the socket.
127361847f8eSopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
127461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
127561847f8eSopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
127661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
127761847f8eSopenharmony_ci     * @crossplatform
127861847f8eSopenharmony_ci     * @since 12
127961847f8eSopenharmony_ci     */
128061847f8eSopenharmony_ci    getLoopbackMode(): Promise<boolean>;
128161847f8eSopenharmony_ci  }
128261847f8eSopenharmony_ci
128361847f8eSopenharmony_ci  /**
128461847f8eSopenharmony_ci   * Defines a LocalSocket connection.
128561847f8eSopenharmony_ci   * @interface LocalSocket
128661847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
128761847f8eSopenharmony_ci   * @since 11
128861847f8eSopenharmony_ci   */
128961847f8eSopenharmony_ci  /**
129061847f8eSopenharmony_ci   * Defines a LocalSocket connection.
129161847f8eSopenharmony_ci   * @interface LocalSocket
129261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
129361847f8eSopenharmony_ci   * @crossplatform
129461847f8eSopenharmony_ci   * @since 12
129561847f8eSopenharmony_ci   */
129661847f8eSopenharmony_ci  export interface LocalSocket {
129761847f8eSopenharmony_ci    /**
129861847f8eSopenharmony_ci     * Binds the Local address.
129961847f8eSopenharmony_ci     * @param { LocalAddress } address - Destination address. {@link LocalAddress}
130061847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
130161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
130261847f8eSopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
130361847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
130461847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address already in use.
130561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
130661847f8eSopenharmony_ci     * @since 11
130761847f8eSopenharmony_ci     */
130861847f8eSopenharmony_ci    /**
130961847f8eSopenharmony_ci     * Binds the Local address.
131061847f8eSopenharmony_ci     * @param { LocalAddress } address - Destination address. {@link LocalAddress}
131161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
131261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
131361847f8eSopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
131461847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
131561847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address already in use.
131661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
131761847f8eSopenharmony_ci     * @crossplatform
131861847f8eSopenharmony_ci     * @since 12
131961847f8eSopenharmony_ci     */
132061847f8eSopenharmony_ci    bind(address: LocalAddress): Promise<void>;
132161847f8eSopenharmony_ci
132261847f8eSopenharmony_ci    /**
132361847f8eSopenharmony_ci     * Sets up a connection to the specified Local address .
132461847f8eSopenharmony_ci     * @param { LocalConnectOptions } options - Optional parameters {@link LocalConnectOptions}.
132561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
132661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
132761847f8eSopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
132861847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
132961847f8eSopenharmony_ci     * @throws { BusinessError } 2301111 - Connection refused.
133061847f8eSopenharmony_ci     * @throws { BusinessError } 2301099 - Cannot assign requested address.
133161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
133261847f8eSopenharmony_ci     * @since 11
133361847f8eSopenharmony_ci     */
133461847f8eSopenharmony_ci    /**
133561847f8eSopenharmony_ci     * Sets up a connection to the specified Local address .
133661847f8eSopenharmony_ci     * @param { LocalConnectOptions } options - Optional parameters {@link LocalConnectOptions}.
133761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
133861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
133961847f8eSopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
134061847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
134161847f8eSopenharmony_ci     * @throws { BusinessError } 2301111 - Connection refused.
134261847f8eSopenharmony_ci     * @throws { BusinessError } 2301099 - Cannot assign requested address.
134361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
134461847f8eSopenharmony_ci     * @crossplatform
134561847f8eSopenharmony_ci     * @since 12
134661847f8eSopenharmony_ci     */
134761847f8eSopenharmony_ci    connect(options: LocalConnectOptions): Promise<void>;
134861847f8eSopenharmony_ci
134961847f8eSopenharmony_ci    /**
135061847f8eSopenharmony_ci     * Sends data over a LocalSocket connection.
135161847f8eSopenharmony_ci     * @param { LocalSendOptions } options - Optional parameters {@link LocalSendOptions}.
135261847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
135361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
135461847f8eSopenharmony_ci     * @throws { BusinessError } 2301011 - Operation would block.
135561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
135661847f8eSopenharmony_ci     * @since 11
135761847f8eSopenharmony_ci     */
135861847f8eSopenharmony_ci    /**
135961847f8eSopenharmony_ci     * Sends data over a LocalSocket connection.
136061847f8eSopenharmony_ci     * @param { LocalSendOptions } options - Optional parameters {@link LocalSendOptions}.
136161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
136261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
136361847f8eSopenharmony_ci     * @throws { BusinessError } 2301011 - Operation would block.
136461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
136561847f8eSopenharmony_ci     * @crossplatform
136661847f8eSopenharmony_ci     * @since 12
136761847f8eSopenharmony_ci     */
136861847f8eSopenharmony_ci    send(options: LocalSendOptions): Promise<void>;
136961847f8eSopenharmony_ci
137061847f8eSopenharmony_ci    /**
137161847f8eSopenharmony_ci     * Closes a LocalSocket connection.
137261847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
137361847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
137461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
137561847f8eSopenharmony_ci     * @since 11
137661847f8eSopenharmony_ci     */
137761847f8eSopenharmony_ci    /**
137861847f8eSopenharmony_ci     * Closes a LocalSocket connection.
137961847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
138061847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
138161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
138261847f8eSopenharmony_ci     * @crossplatform
138361847f8eSopenharmony_ci     * @since 12
138461847f8eSopenharmony_ci     */
138561847f8eSopenharmony_ci    close(): Promise<void>;
138661847f8eSopenharmony_ci
138761847f8eSopenharmony_ci    /**
138861847f8eSopenharmony_ci     * Obtains the status of the LocalSocket connection.
138961847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
139061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
139161847f8eSopenharmony_ci     * @since 11
139261847f8eSopenharmony_ci     */
139361847f8eSopenharmony_ci    /**
139461847f8eSopenharmony_ci     * Obtains the status of the LocalSocket connection.
139561847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
139661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
139761847f8eSopenharmony_ci     * @crossplatform
139861847f8eSopenharmony_ci     * @since 12
139961847f8eSopenharmony_ci     */
140061847f8eSopenharmony_ci    getState(): Promise<SocketStateBase>;
140161847f8eSopenharmony_ci
140261847f8eSopenharmony_ci    /**
140361847f8eSopenharmony_ci     * Obtains the file descriptor of the LocalSocket connection.
140461847f8eSopenharmony_ci     * @returns { Promise<number> } The promise returns the file descriptor of the LocalSocket connection.
140561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
140661847f8eSopenharmony_ci     * @since 11
140761847f8eSopenharmony_ci     */
140861847f8eSopenharmony_ci    /**
140961847f8eSopenharmony_ci     * Obtains the file descriptor of the LocalSocket connection.
141061847f8eSopenharmony_ci     * @returns { Promise<number> } The promise returns the file descriptor of the LocalSocket connection.
141161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
141261847f8eSopenharmony_ci     * @crossplatform
141361847f8eSopenharmony_ci     * @since 12
141461847f8eSopenharmony_ci     */
141561847f8eSopenharmony_ci    getSocketFd(): Promise<number>;
141661847f8eSopenharmony_ci
141761847f8eSopenharmony_ci    /**
141861847f8eSopenharmony_ci     * Sets other attributes of the LocalSocket connection.
141961847f8eSopenharmony_ci     * @param { ExtraOptionsBase } options - Optional parameters {@link ExtraOptionsBase}.
142061847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
142161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
142261847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
142361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
142461847f8eSopenharmony_ci     * @since 11
142561847f8eSopenharmony_ci     */
142661847f8eSopenharmony_ci    /**
142761847f8eSopenharmony_ci     * Sets other attributes of the LocalSocket connection.
142861847f8eSopenharmony_ci     * @param { ExtraOptionsBase } options - Optional parameters {@link ExtraOptionsBase}.
142961847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
143061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
143161847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
143261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
143361847f8eSopenharmony_ci     * @crossplatform
143461847f8eSopenharmony_ci     * @since 12
143561847f8eSopenharmony_ci     */
143661847f8eSopenharmony_ci    setExtraOptions(options: ExtraOptionsBase): Promise<void>;
143761847f8eSopenharmony_ci
143861847f8eSopenharmony_ci    /**
143961847f8eSopenharmony_ci     * Gets other attributes of the LocalSocket connection.
144061847f8eSopenharmony_ci     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
144161847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
144261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
144361847f8eSopenharmony_ci     * @since 11
144461847f8eSopenharmony_ci     */
144561847f8eSopenharmony_ci    /**
144661847f8eSopenharmony_ci     * Gets other attributes of the LocalSocket connection.
144761847f8eSopenharmony_ci     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
144861847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
144961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
145061847f8eSopenharmony_ci     * @crossplatform
145161847f8eSopenharmony_ci     * @since 12
145261847f8eSopenharmony_ci     */
145361847f8eSopenharmony_ci    getExtraOptions(): Promise<ExtraOptionsBase>;
145461847f8eSopenharmony_ci
145561847f8eSopenharmony_ci    /**
145661847f8eSopenharmony_ci     * Obtains the local address of a LocalSocket connection.
145761847f8eSopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
145861847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
145961847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
146061847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
146161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
146261847f8eSopenharmony_ci     * @since 12
146361847f8eSopenharmony_ci     */
146461847f8eSopenharmony_ci    getLocalAddress(): Promise<string>;
146561847f8eSopenharmony_ci
146661847f8eSopenharmony_ci    /**
146761847f8eSopenharmony_ci     * Listens for message receiving events of the LocalSocket connection.
146861847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
146961847f8eSopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
147061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
147161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
147261847f8eSopenharmony_ci     * @since 11
147361847f8eSopenharmony_ci     */
147461847f8eSopenharmony_ci    /**
147561847f8eSopenharmony_ci     * Listens for message receiving events of the LocalSocket connection.
147661847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
147761847f8eSopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
147861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
147961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
148061847f8eSopenharmony_ci     * @crossplatform
148161847f8eSopenharmony_ci     * @since 12
148261847f8eSopenharmony_ci     */
148361847f8eSopenharmony_ci    on(type: 'message', callback: Callback<LocalSocketMessageInfo>): void;
148461847f8eSopenharmony_ci
148561847f8eSopenharmony_ci    /**
148661847f8eSopenharmony_ci     * Cancels listening for message receiving events of the LocalSocket connection.
148761847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
148861847f8eSopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
148961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
149061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
149161847f8eSopenharmony_ci     * @since 11
149261847f8eSopenharmony_ci     */
149361847f8eSopenharmony_ci    /**
149461847f8eSopenharmony_ci     * Cancels listening for message receiving events of the LocalSocket connection.
149561847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
149661847f8eSopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
149761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
149861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
149961847f8eSopenharmony_ci     * @crossplatform
150061847f8eSopenharmony_ci     * @since 12
150161847f8eSopenharmony_ci     */
150261847f8eSopenharmony_ci    off(type: 'message', callback?: Callback<LocalSocketMessageInfo>): void;
150361847f8eSopenharmony_ci
150461847f8eSopenharmony_ci    /**
150561847f8eSopenharmony_ci     * Listens for connection events of the LocalSocket connection.
150661847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
150761847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
150861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
150961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
151061847f8eSopenharmony_ci     * @since 11
151161847f8eSopenharmony_ci     */
151261847f8eSopenharmony_ci    /**
151361847f8eSopenharmony_ci     * Listens for connection events of the LocalSocket connection.
151461847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
151561847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
151661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
151761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
151861847f8eSopenharmony_ci     * @crossplatform
151961847f8eSopenharmony_ci     * @since 12
152061847f8eSopenharmony_ci     */
152161847f8eSopenharmony_ci    on(type: 'connect', callback: Callback<void>): void;
152261847f8eSopenharmony_ci
152361847f8eSopenharmony_ci    /**
152461847f8eSopenharmony_ci     * Cancels listening for connection events of the LocalSocket connection.
152561847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
152661847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
152761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
152861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
152961847f8eSopenharmony_ci     * @since 11
153061847f8eSopenharmony_ci     */
153161847f8eSopenharmony_ci    /**
153261847f8eSopenharmony_ci     * Cancels listening for connection events of the LocalSocket connection.
153361847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
153461847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
153561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
153661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
153761847f8eSopenharmony_ci     * @crossplatform
153861847f8eSopenharmony_ci     * @since 12
153961847f8eSopenharmony_ci     */
154061847f8eSopenharmony_ci    off(type: 'connect', callback?: Callback<void>): void;
154161847f8eSopenharmony_ci
154261847f8eSopenharmony_ci    /**
154361847f8eSopenharmony_ci     * Listens for close events of the LocalSocket connection.
154461847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
154561847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
154661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
154761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
154861847f8eSopenharmony_ci     * @since 11
154961847f8eSopenharmony_ci     */
155061847f8eSopenharmony_ci    /**
155161847f8eSopenharmony_ci     * Listens for close events of the LocalSocket connection.
155261847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
155361847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
155461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
155561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
155661847f8eSopenharmony_ci     * @crossplatform
155761847f8eSopenharmony_ci     * @since 12
155861847f8eSopenharmony_ci     */
155961847f8eSopenharmony_ci    on(type: 'close', callback: Callback<void>): void;
156061847f8eSopenharmony_ci
156161847f8eSopenharmony_ci    /**
156261847f8eSopenharmony_ci     * Cancels listening for close events of the LocalSocket connection.
156361847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
156461847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
156561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
156661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
156761847f8eSopenharmony_ci     * @since 11
156861847f8eSopenharmony_ci     */
156961847f8eSopenharmony_ci    /**
157061847f8eSopenharmony_ci     * Cancels listening for close events of the LocalSocket connection.
157161847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
157261847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
157361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
157461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
157561847f8eSopenharmony_ci     * @crossplatform
157661847f8eSopenharmony_ci     * @since 12
157761847f8eSopenharmony_ci     */
157861847f8eSopenharmony_ci    off(type: 'close', callback?: Callback<void>): void;
157961847f8eSopenharmony_ci
158061847f8eSopenharmony_ci    /**
158161847f8eSopenharmony_ci     * Listens for error events of the LocalSocket connection.
158261847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
158361847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
158461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
158561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
158661847f8eSopenharmony_ci     * @since 11
158761847f8eSopenharmony_ci     */
158861847f8eSopenharmony_ci    /**
158961847f8eSopenharmony_ci     * Listens for error events of the LocalSocket connection.
159061847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
159161847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
159261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
159361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
159461847f8eSopenharmony_ci     * @crossplatform
159561847f8eSopenharmony_ci     * @since 12
159661847f8eSopenharmony_ci     */
159761847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
159861847f8eSopenharmony_ci
159961847f8eSopenharmony_ci    /**
160061847f8eSopenharmony_ci     * Cancels listening for error events of the LocalSocket connection.
160161847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
160261847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
160361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
160461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
160561847f8eSopenharmony_ci     * @since 11
160661847f8eSopenharmony_ci     */
160761847f8eSopenharmony_ci    /**
160861847f8eSopenharmony_ci     * Cancels listening for error events of the LocalSocket connection.
160961847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
161061847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
161161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
161261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
161361847f8eSopenharmony_ci     * @crossplatform
161461847f8eSopenharmony_ci     * @since 12
161561847f8eSopenharmony_ci     */
161661847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
161761847f8eSopenharmony_ci  }
161861847f8eSopenharmony_ci
161961847f8eSopenharmony_ci  /**
162061847f8eSopenharmony_ci   * Defines the connection of the LocalSocket client and server.
162161847f8eSopenharmony_ci   * @interface LocalSocketConnection
162261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
162361847f8eSopenharmony_ci   * @since 11
162461847f8eSopenharmony_ci   */
162561847f8eSopenharmony_ci  /**
162661847f8eSopenharmony_ci   * Defines the connection of the LocalSocket client and server.
162761847f8eSopenharmony_ci   * @interface LocalSocketConnection
162861847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
162961847f8eSopenharmony_ci   * @crossplatform
163061847f8eSopenharmony_ci   * @since 12
163161847f8eSopenharmony_ci   */
163261847f8eSopenharmony_ci  export interface LocalSocketConnection {
163361847f8eSopenharmony_ci    /**
163461847f8eSopenharmony_ci     * The id of a client connects to the LocalSocketServer.
163561847f8eSopenharmony_ci     * @type {number}
163661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
163761847f8eSopenharmony_ci     * @since 11
163861847f8eSopenharmony_ci     */
163961847f8eSopenharmony_ci    /**
164061847f8eSopenharmony_ci     * The id of a client connects to the LocalSocketServer.
164161847f8eSopenharmony_ci     * @type {number}
164261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
164361847f8eSopenharmony_ci     * @crossplatform
164461847f8eSopenharmony_ci     * @since 12
164561847f8eSopenharmony_ci     */
164661847f8eSopenharmony_ci    clientId: number;
164761847f8eSopenharmony_ci
164861847f8eSopenharmony_ci    /**
164961847f8eSopenharmony_ci     * Sends data over a LocalSocketServer connection to client.
165061847f8eSopenharmony_ci     * @param { LocalSendOptions } options - Parameters for sending data {@link LocalSendOptions}.
165161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
165261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
165361847f8eSopenharmony_ci     * @throws { BusinessError } 2301011 - Operation would block.
165461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
165561847f8eSopenharmony_ci     * @since 11
165661847f8eSopenharmony_ci     */
165761847f8eSopenharmony_ci    /**
165861847f8eSopenharmony_ci     * Sends data over a LocalSocketServer connection to client.
165961847f8eSopenharmony_ci     * @param { LocalSendOptions } options - Parameters for sending data {@link LocalSendOptions}.
166061847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
166161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
166261847f8eSopenharmony_ci     * @throws { BusinessError } 2301011 - Operation would block.
166361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
166461847f8eSopenharmony_ci     * @crossplatform
166561847f8eSopenharmony_ci     * @since 12
166661847f8eSopenharmony_ci     */
166761847f8eSopenharmony_ci    send(options: LocalSendOptions): Promise<void>;
166861847f8eSopenharmony_ci
166961847f8eSopenharmony_ci    /**
167061847f8eSopenharmony_ci     * Closes a LocalSocket client connection.
167161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
167261847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
167361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
167461847f8eSopenharmony_ci     * @since 11
167561847f8eSopenharmony_ci     */
167661847f8eSopenharmony_ci    /**
167761847f8eSopenharmony_ci     * Closes a LocalSocket client connection.
167861847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
167961847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
168061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
168161847f8eSopenharmony_ci     * @crossplatform
168261847f8eSopenharmony_ci     * @since 12
168361847f8eSopenharmony_ci     */
168461847f8eSopenharmony_ci    close(): Promise<void>;
168561847f8eSopenharmony_ci
168661847f8eSopenharmony_ci    /**
168761847f8eSopenharmony_ci     * Obtains the local address of a LocalSocket client connection.
168861847f8eSopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
168961847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
169061847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
169161847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
169261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
169361847f8eSopenharmony_ci     * @since 12
169461847f8eSopenharmony_ci     */
169561847f8eSopenharmony_ci    getLocalAddress(): Promise<string>;
169661847f8eSopenharmony_ci
169761847f8eSopenharmony_ci    /**
169861847f8eSopenharmony_ci     * Listens for message receiving events of the LocalSocketConnection.
169961847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
170061847f8eSopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of on.
170161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
170261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
170361847f8eSopenharmony_ci     * @since 11
170461847f8eSopenharmony_ci     */
170561847f8eSopenharmony_ci    /**
170661847f8eSopenharmony_ci     * Listens for message receiving events of the LocalSocketConnection.
170761847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
170861847f8eSopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of on.
170961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
171061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
171161847f8eSopenharmony_ci     * @crossplatform
171261847f8eSopenharmony_ci     * @since 12
171361847f8eSopenharmony_ci     */
171461847f8eSopenharmony_ci    on(type: 'message', callback: Callback<LocalSocketMessageInfo>): void;
171561847f8eSopenharmony_ci
171661847f8eSopenharmony_ci    /**
171761847f8eSopenharmony_ci     * Cancels listening for message receiving events of the LocalSocketConnection.
171861847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
171961847f8eSopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of off.
172061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
172161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
172261847f8eSopenharmony_ci     * @since 11
172361847f8eSopenharmony_ci     */
172461847f8eSopenharmony_ci    /**
172561847f8eSopenharmony_ci     * Cancels listening for message receiving events of the LocalSocketConnection.
172661847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
172761847f8eSopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of off.
172861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
172961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
173061847f8eSopenharmony_ci     * @crossplatform
173161847f8eSopenharmony_ci     * @since 12
173261847f8eSopenharmony_ci     */
173361847f8eSopenharmony_ci    off(type: 'message', callback?: Callback<LocalSocketMessageInfo>): void;
173461847f8eSopenharmony_ci
173561847f8eSopenharmony_ci    /**
173661847f8eSopenharmony_ci     * Listens for close events of the LocalSocketConnection.
173761847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
173861847f8eSopenharmony_ci     * @param { Callback<void> } callback - The callback of on.
173961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
174061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
174161847f8eSopenharmony_ci     * @since 11
174261847f8eSopenharmony_ci     */
174361847f8eSopenharmony_ci    /**
174461847f8eSopenharmony_ci     * Listens for close events of the LocalSocketConnection.
174561847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
174661847f8eSopenharmony_ci     * @param { Callback<void> } callback - The callback of on.
174761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
174861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
174961847f8eSopenharmony_ci     * @crossplatform
175061847f8eSopenharmony_ci     * @since 12
175161847f8eSopenharmony_ci     */
175261847f8eSopenharmony_ci    on(type: 'close', callback: Callback<void>): void;
175361847f8eSopenharmony_ci
175461847f8eSopenharmony_ci    /**
175561847f8eSopenharmony_ci     * Cancels listening for close events of the LocalSocketConnection.
175661847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
175761847f8eSopenharmony_ci     * @param { Callback<void> } callback - The callback of off.
175861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
175961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
176061847f8eSopenharmony_ci     * @since 11
176161847f8eSopenharmony_ci     */
176261847f8eSopenharmony_ci    /**
176361847f8eSopenharmony_ci     * Cancels listening for close events of the LocalSocketConnection.
176461847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
176561847f8eSopenharmony_ci     * @param { Callback<void> } callback - The callback of off.
176661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
176761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
176861847f8eSopenharmony_ci     * @crossplatform
176961847f8eSopenharmony_ci     * @since 12
177061847f8eSopenharmony_ci     */
177161847f8eSopenharmony_ci    off(type: 'close', callback?: Callback<void>): void;
177261847f8eSopenharmony_ci
177361847f8eSopenharmony_ci    /**
177461847f8eSopenharmony_ci     * Listens for error events of the LocalSocketConnection.
177561847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
177661847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
177761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
177861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
177961847f8eSopenharmony_ci     * @since 11
178061847f8eSopenharmony_ci     */
178161847f8eSopenharmony_ci    /**
178261847f8eSopenharmony_ci     * Listens for error events of the LocalSocketConnection.
178361847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
178461847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
178561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
178661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
178761847f8eSopenharmony_ci     * @crossplatform
178861847f8eSopenharmony_ci     * @since 12
178961847f8eSopenharmony_ci     */
179061847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
179161847f8eSopenharmony_ci
179261847f8eSopenharmony_ci    /**
179361847f8eSopenharmony_ci     * Cancels listening for error events of the LocalSocketConnection.
179461847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
179561847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
179661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
179761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
179861847f8eSopenharmony_ci     * @since 11
179961847f8eSopenharmony_ci     */
180061847f8eSopenharmony_ci    /**
180161847f8eSopenharmony_ci     * Cancels listening for error events of the LocalSocketConnection.
180261847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
180361847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
180461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
180561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
180661847f8eSopenharmony_ci     * @crossplatform
180761847f8eSopenharmony_ci     * @since 12
180861847f8eSopenharmony_ci     */
180961847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
181061847f8eSopenharmony_ci  }
181161847f8eSopenharmony_ci
181261847f8eSopenharmony_ci  /**
181361847f8eSopenharmony_ci   * Defines a LocalSocket server connection.
181461847f8eSopenharmony_ci   * @interface LocalSocketServer
181561847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
181661847f8eSopenharmony_ci   * @since 11
181761847f8eSopenharmony_ci   */
181861847f8eSopenharmony_ci  /**
181961847f8eSopenharmony_ci   * Defines a LocalSocket server connection.
182061847f8eSopenharmony_ci   * @interface LocalSocketServer
182161847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
182261847f8eSopenharmony_ci   * @crossplatform
182361847f8eSopenharmony_ci   * @since 12
182461847f8eSopenharmony_ci   */
182561847f8eSopenharmony_ci  export interface LocalSocketServer {
182661847f8eSopenharmony_ci    /**
182761847f8eSopenharmony_ci     * Binds the Local address.
182861847f8eSopenharmony_ci     * <p>Listens for a LocalSocket connection to be made to this socket and accepts it. This interface uses multiple threads
182961847f8eSopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
183061847f8eSopenharmony_ci     * @param { LocalAddress } address - Network address information {@link LocalAddress}.
183161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
183261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
183361847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
183461847f8eSopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
183561847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
183661847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address already in use.
183761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
183861847f8eSopenharmony_ci     * @since 11
183961847f8eSopenharmony_ci     */
184061847f8eSopenharmony_ci    /**
184161847f8eSopenharmony_ci     * Binds the Local address.
184261847f8eSopenharmony_ci     * <p>Listens for a LocalSocket connection to be made to this socket and accepts it. This interface uses multiple threads
184361847f8eSopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
184461847f8eSopenharmony_ci     * @param { LocalAddress } address - Network address information {@link LocalAddress}.
184561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
184661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
184761847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
184861847f8eSopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
184961847f8eSopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
185061847f8eSopenharmony_ci     * @throws { BusinessError } 2301098 - Address already in use.
185161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
185261847f8eSopenharmony_ci     * @crossplatform
185361847f8eSopenharmony_ci     * @since 12
185461847f8eSopenharmony_ci     */
185561847f8eSopenharmony_ci    listen(address: LocalAddress): Promise<void>;
185661847f8eSopenharmony_ci
185761847f8eSopenharmony_ci    /**
185861847f8eSopenharmony_ci     * Obtains the status of the LocalSocketServer connection.
185961847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
186061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
186161847f8eSopenharmony_ci     * @since 11
186261847f8eSopenharmony_ci     */
186361847f8eSopenharmony_ci    /**
186461847f8eSopenharmony_ci     * Obtains the status of the LocalSocketServer connection.
186561847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
186661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
186761847f8eSopenharmony_ci     * @crossplatform
186861847f8eSopenharmony_ci     * @since 12
186961847f8eSopenharmony_ci     */
187061847f8eSopenharmony_ci    getState(): Promise<SocketStateBase>;
187161847f8eSopenharmony_ci
187261847f8eSopenharmony_ci    /**
187361847f8eSopenharmony_ci     * Sets other attributes of the LocalSocketServer connection.
187461847f8eSopenharmony_ci     * @param { ExtraOptionsBase } options - Parameters of the attributes {@link ExtraOptionsBase}.
187561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
187661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
187761847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
187861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
187961847f8eSopenharmony_ci     * @since 11
188061847f8eSopenharmony_ci     */
188161847f8eSopenharmony_ci    /**
188261847f8eSopenharmony_ci     * Sets other attributes of the LocalSocketServer connection.
188361847f8eSopenharmony_ci     * @param { ExtraOptionsBase } options - Parameters of the attributes {@link ExtraOptionsBase}.
188461847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
188561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
188661847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
188761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
188861847f8eSopenharmony_ci     * @crossplatform
188961847f8eSopenharmony_ci     * @since 12
189061847f8eSopenharmony_ci     */
189161847f8eSopenharmony_ci    setExtraOptions(options: ExtraOptionsBase): Promise<void>;
189261847f8eSopenharmony_ci
189361847f8eSopenharmony_ci    /**
189461847f8eSopenharmony_ci     * Gets other attributes of the LocalSocket connection.
189561847f8eSopenharmony_ci     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
189661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
189761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
189861847f8eSopenharmony_ci     * @since 11
189961847f8eSopenharmony_ci     */
190061847f8eSopenharmony_ci    /**
190161847f8eSopenharmony_ci     * Gets other attributes of the LocalSocket connection.
190261847f8eSopenharmony_ci     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
190361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
190461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
190561847f8eSopenharmony_ci     * @crossplatform
190661847f8eSopenharmony_ci     * @since 12
190761847f8eSopenharmony_ci     */
190861847f8eSopenharmony_ci    getExtraOptions(): Promise<ExtraOptionsBase>;
190961847f8eSopenharmony_ci
191061847f8eSopenharmony_ci    /**
191161847f8eSopenharmony_ci     * Obtains the local address of the LocalSocketServer connection.
191261847f8eSopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
191361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
191461847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
191561847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
191661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
191761847f8eSopenharmony_ci     * @since 12
191861847f8eSopenharmony_ci     */
191961847f8eSopenharmony_ci    getLocalAddress(): Promise<string>;
192061847f8eSopenharmony_ci
192161847f8eSopenharmony_ci    /**
192261847f8eSopenharmony_ci     * Listens for connect events of the LocalSocketServer connection.
192361847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
192461847f8eSopenharmony_ci     * @param { Callback<LocalSocketConnection> } callback - The callback of on.
192561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
192661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
192761847f8eSopenharmony_ci     * @since 11
192861847f8eSopenharmony_ci     */
192961847f8eSopenharmony_ci    /**
193061847f8eSopenharmony_ci     * Listens for connect events of the LocalSocketServer connection.
193161847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
193261847f8eSopenharmony_ci     * @param { Callback<LocalSocketConnection> } callback - The callback of on.
193361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
193461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
193561847f8eSopenharmony_ci     * @crossplatform
193661847f8eSopenharmony_ci     * @since 12
193761847f8eSopenharmony_ci     */
193861847f8eSopenharmony_ci    on(type: 'connect', callback: Callback<LocalSocketConnection>): void;
193961847f8eSopenharmony_ci
194061847f8eSopenharmony_ci    /**
194161847f8eSopenharmony_ci     * Cancels listening for connect events of the LocalSocketServer connection.
194261847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
194361847f8eSopenharmony_ci     * @param { Callback<LocalSocketConnection> } callback - The callback of off.
194461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
194561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
194661847f8eSopenharmony_ci     * @since 11
194761847f8eSopenharmony_ci     */
194861847f8eSopenharmony_ci    /**
194961847f8eSopenharmony_ci     * Cancels listening for connect events of the LocalSocketServer connection.
195061847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
195161847f8eSopenharmony_ci     * @param { Callback<LocalSocketConnection> } callback - The callback of off.
195261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
195361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
195461847f8eSopenharmony_ci     * @crossplatform
195561847f8eSopenharmony_ci     * @since 12
195661847f8eSopenharmony_ci     */
195761847f8eSopenharmony_ci    off(type: 'connect', callback?: Callback<LocalSocketConnection>): void;
195861847f8eSopenharmony_ci
195961847f8eSopenharmony_ci    /**
196061847f8eSopenharmony_ci     * Listens for error events of the LocalSocketServer connection.
196161847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
196261847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
196361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
196461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
196561847f8eSopenharmony_ci     * @since 11
196661847f8eSopenharmony_ci     */
196761847f8eSopenharmony_ci    /**
196861847f8eSopenharmony_ci     * Listens for error events of the LocalSocketServer connection.
196961847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
197061847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
197161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
197261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
197361847f8eSopenharmony_ci     * @crossplatform
197461847f8eSopenharmony_ci     * @since 12
197561847f8eSopenharmony_ci     */
197661847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
197761847f8eSopenharmony_ci
197861847f8eSopenharmony_ci    /**
197961847f8eSopenharmony_ci     * Cancels listening for error events of the LocalSocketServer connection.
198061847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
198161847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
198261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
198361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
198461847f8eSopenharmony_ci     * @since 11
198561847f8eSopenharmony_ci     */
198661847f8eSopenharmony_ci    /**
198761847f8eSopenharmony_ci     * Cancels listening for error events of the LocalSocketServer connection.
198861847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
198961847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
199061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
199161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
199261847f8eSopenharmony_ci     * @crossplatform
199361847f8eSopenharmony_ci     * @since 12
199461847f8eSopenharmony_ci     */
199561847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
199661847f8eSopenharmony_ci  }
199761847f8eSopenharmony_ci
199861847f8eSopenharmony_ci  /**
199961847f8eSopenharmony_ci   * Defines TCPSocket connection parameters.
200061847f8eSopenharmony_ci   * @interface TCPConnectOptions
200161847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
200261847f8eSopenharmony_ci   * @since 7
200361847f8eSopenharmony_ci   */
200461847f8eSopenharmony_ci  /**
200561847f8eSopenharmony_ci   * Defines TCPSocket connection parameters.
200661847f8eSopenharmony_ci   * @interface TCPConnectOptions
200761847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
200861847f8eSopenharmony_ci   * @crossplatform
200961847f8eSopenharmony_ci   * @since 10
201061847f8eSopenharmony_ci   */
201161847f8eSopenharmony_ci  export interface TCPConnectOptions {
201261847f8eSopenharmony_ci    /**
201361847f8eSopenharmony_ci     * Bound IP address and port number.
201461847f8eSopenharmony_ci     * @type { NetAddress }
201561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
201661847f8eSopenharmony_ci     * @since 7
201761847f8eSopenharmony_ci     */
201861847f8eSopenharmony_ci    /**
201961847f8eSopenharmony_ci     * Bound IP address and port number.
202061847f8eSopenharmony_ci     * @type { NetAddress }
202161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
202261847f8eSopenharmony_ci     * @crossplatform
202361847f8eSopenharmony_ci     * @since 10
202461847f8eSopenharmony_ci     */
202561847f8eSopenharmony_ci    address: NetAddress;
202661847f8eSopenharmony_ci
202761847f8eSopenharmony_ci    /**
202861847f8eSopenharmony_ci     * Timeout duration of the TCPSocket connection, in milliseconds.
202961847f8eSopenharmony_ci     * @type { ?number }
203061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
203161847f8eSopenharmony_ci     * @since 7
203261847f8eSopenharmony_ci     */
203361847f8eSopenharmony_ci    /**
203461847f8eSopenharmony_ci     * Timeout duration of the TCPSocket connection, in milliseconds.
203561847f8eSopenharmony_ci     * @type { ?number }
203661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
203761847f8eSopenharmony_ci     * @crossplatform
203861847f8eSopenharmony_ci     * @since 10
203961847f8eSopenharmony_ci     */
204061847f8eSopenharmony_ci    timeout?: number;
204161847f8eSopenharmony_ci  }
204261847f8eSopenharmony_ci
204361847f8eSopenharmony_ci  /**
204461847f8eSopenharmony_ci   * Defines the parameters for sending data over the TCPSocket connection.
204561847f8eSopenharmony_ci   * @interface TCPSendOptions
204661847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
204761847f8eSopenharmony_ci   * @since 7
204861847f8eSopenharmony_ci   */
204961847f8eSopenharmony_ci  /**
205061847f8eSopenharmony_ci   * Defines the parameters for sending data over the TCPSocket connection.
205161847f8eSopenharmony_ci   * @interface TCPSendOptions
205261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
205361847f8eSopenharmony_ci   * @crossplatform
205461847f8eSopenharmony_ci   * @since 10
205561847f8eSopenharmony_ci   */
205661847f8eSopenharmony_ci  export interface TCPSendOptions {
205761847f8eSopenharmony_ci    /**
205861847f8eSopenharmony_ci     * Data to send.
205961847f8eSopenharmony_ci     * @type { string | ArrayBuffer }
206061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
206161847f8eSopenharmony_ci     * @since 7
206261847f8eSopenharmony_ci     */
206361847f8eSopenharmony_ci    /**
206461847f8eSopenharmony_ci     * Data to send.
206561847f8eSopenharmony_ci     * @type { string | ArrayBuffer }
206661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
206761847f8eSopenharmony_ci     * @crossplatform
206861847f8eSopenharmony_ci     * @since 10
206961847f8eSopenharmony_ci     */
207061847f8eSopenharmony_ci    data: string | ArrayBuffer;
207161847f8eSopenharmony_ci
207261847f8eSopenharmony_ci    /**
207361847f8eSopenharmony_ci     * Character encoding format.
207461847f8eSopenharmony_ci     * @type { ?string }
207561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
207661847f8eSopenharmony_ci     * @since 7
207761847f8eSopenharmony_ci     */
207861847f8eSopenharmony_ci    /**
207961847f8eSopenharmony_ci     * Character encoding format.
208061847f8eSopenharmony_ci     * @type { ?string }
208161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
208261847f8eSopenharmony_ci     * @crossplatform
208361847f8eSopenharmony_ci     * @since 10
208461847f8eSopenharmony_ci     */
208561847f8eSopenharmony_ci    encoding?: string;
208661847f8eSopenharmony_ci  }
208761847f8eSopenharmony_ci
208861847f8eSopenharmony_ci  /**
208961847f8eSopenharmony_ci   * Defines other properties of the TCPSocket connection.
209061847f8eSopenharmony_ci   * @interface TCPExtraOptions
209161847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
209261847f8eSopenharmony_ci   * @since 7
209361847f8eSopenharmony_ci   */
209461847f8eSopenharmony_ci  /**
209561847f8eSopenharmony_ci   * Defines other properties of the TCPSocket connection.
209661847f8eSopenharmony_ci   * @interface TCPExtraOptions
209761847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
209861847f8eSopenharmony_ci   * @crossplatform
209961847f8eSopenharmony_ci   * @since 10
210061847f8eSopenharmony_ci   */
210161847f8eSopenharmony_ci  export interface TCPExtraOptions extends ExtraOptionsBase {
210261847f8eSopenharmony_ci    /**
210361847f8eSopenharmony_ci     * Whether to keep the connection alive. The default value is false.
210461847f8eSopenharmony_ci     * @type { ?boolean }
210561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
210661847f8eSopenharmony_ci     * @since 7
210761847f8eSopenharmony_ci     */
210861847f8eSopenharmony_ci    /**
210961847f8eSopenharmony_ci     * Whether to keep the connection alive. The default value is false.
211061847f8eSopenharmony_ci     * @type { ?boolean }
211161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
211261847f8eSopenharmony_ci     * @crossplatform
211361847f8eSopenharmony_ci     * @since 10
211461847f8eSopenharmony_ci     */
211561847f8eSopenharmony_ci    keepAlive?: boolean;
211661847f8eSopenharmony_ci
211761847f8eSopenharmony_ci    /**
211861847f8eSopenharmony_ci     * Whether to enable OOBInline. The default value is false.
211961847f8eSopenharmony_ci     * @type { ?boolean }
212061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
212161847f8eSopenharmony_ci     * @since 7
212261847f8eSopenharmony_ci     */
212361847f8eSopenharmony_ci    /**
212461847f8eSopenharmony_ci     * Whether to enable OOBInline. The default value is false.
212561847f8eSopenharmony_ci     * @type { ?boolean }
212661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
212761847f8eSopenharmony_ci     * @crossplatform
212861847f8eSopenharmony_ci     * @since 10
212961847f8eSopenharmony_ci     */
213061847f8eSopenharmony_ci    OOBInline?: boolean;
213161847f8eSopenharmony_ci
213261847f8eSopenharmony_ci    /**
213361847f8eSopenharmony_ci     * Whether to enable no-delay on the TCPSocket connection. The default value is false.
213461847f8eSopenharmony_ci     * @type { ?boolean }
213561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
213661847f8eSopenharmony_ci     * @since 7
213761847f8eSopenharmony_ci     */
213861847f8eSopenharmony_ci    /**
213961847f8eSopenharmony_ci     * Whether to enable no-delay on the TCPSocket connection. The default value is false.
214061847f8eSopenharmony_ci     * @type { ?boolean }
214161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
214261847f8eSopenharmony_ci     * @crossplatform
214361847f8eSopenharmony_ci     * @since 10
214461847f8eSopenharmony_ci     */
214561847f8eSopenharmony_ci    TCPNoDelay?: boolean;
214661847f8eSopenharmony_ci
214761847f8eSopenharmony_ci    /**
214861847f8eSopenharmony_ci     * Socket linger.
214961847f8eSopenharmony_ci     * @type { ?object }
215061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
215161847f8eSopenharmony_ci     * @crossplatform
215261847f8eSopenharmony_ci     * @since 7
215361847f8eSopenharmony_ci     */
215461847f8eSopenharmony_ci    /**
215561847f8eSopenharmony_ci     * Socket linger.
215661847f8eSopenharmony_ci     * @type { ?object }
215761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
215861847f8eSopenharmony_ci     * @crossplatform
215961847f8eSopenharmony_ci     * @since 10
216061847f8eSopenharmony_ci     */
216161847f8eSopenharmony_ci    socketLinger?: { on: boolean, linger: number };
216261847f8eSopenharmony_ci  }
216361847f8eSopenharmony_ci
216461847f8eSopenharmony_ci  /**
216561847f8eSopenharmony_ci   * Defines a TCPSocket connection.
216661847f8eSopenharmony_ci   * @interface TCPSocket
216761847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
216861847f8eSopenharmony_ci   * @since 7
216961847f8eSopenharmony_ci   */
217061847f8eSopenharmony_ci  /**
217161847f8eSopenharmony_ci   * Defines a TCPSocket connection.
217261847f8eSopenharmony_ci   * @interface TCPSocket
217361847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
217461847f8eSopenharmony_ci   * @crossplatform
217561847f8eSopenharmony_ci   * @since 10
217661847f8eSopenharmony_ci   */
217761847f8eSopenharmony_ci  export interface TCPSocket {
217861847f8eSopenharmony_ci    /**
217961847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
218061847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
218161847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
218261847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - Return the callback of bind.
218361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
218461847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
218561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
218661847f8eSopenharmony_ci     * @since 7
218761847f8eSopenharmony_ci     */
218861847f8eSopenharmony_ci    /**
218961847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
219061847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
219161847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
219261847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
219361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
219461847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
219561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
219661847f8eSopenharmony_ci     * @crossplatform
219761847f8eSopenharmony_ci     * @since 10
219861847f8eSopenharmony_ci     */
219961847f8eSopenharmony_ci    bind(address: NetAddress, callback: AsyncCallback<void>): void;
220061847f8eSopenharmony_ci
220161847f8eSopenharmony_ci    /**
220261847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
220361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
220461847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
220561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
220661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
220761847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
220861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
220961847f8eSopenharmony_ci     * @since 7
221061847f8eSopenharmony_ci     */
221161847f8eSopenharmony_ci    /**
221261847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
221361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
221461847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
221561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
221661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
221761847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
221861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
221961847f8eSopenharmony_ci     * @crossplatform
222061847f8eSopenharmony_ci     * @since 10
222161847f8eSopenharmony_ci     */
222261847f8eSopenharmony_ci    bind(address: NetAddress): Promise<void>;
222361847f8eSopenharmony_ci
222461847f8eSopenharmony_ci    /**
222561847f8eSopenharmony_ci     * Sets up a connection to the specified IP address and port number.
222661847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
222761847f8eSopenharmony_ci     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
222861847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of connect.
222961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
223061847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
223161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
223261847f8eSopenharmony_ci     * @since 7
223361847f8eSopenharmony_ci     */
223461847f8eSopenharmony_ci    /**
223561847f8eSopenharmony_ci     * Sets up a connection to the specified IP address and port number.
223661847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
223761847f8eSopenharmony_ci     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
223861847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of connect.
223961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
224061847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
224161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
224261847f8eSopenharmony_ci     * @crossplatform
224361847f8eSopenharmony_ci     * @since 10
224461847f8eSopenharmony_ci     */
224561847f8eSopenharmony_ci    connect(options: TCPConnectOptions, callback: AsyncCallback<void>): void;
224661847f8eSopenharmony_ci
224761847f8eSopenharmony_ci    /**
224861847f8eSopenharmony_ci     * Sets up a connection to the specified IP address and port number.
224961847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
225061847f8eSopenharmony_ci     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
225161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
225261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
225361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
225461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
225561847f8eSopenharmony_ci     * @since 7
225661847f8eSopenharmony_ci     */
225761847f8eSopenharmony_ci    /**
225861847f8eSopenharmony_ci     * Sets up a connection to the specified IP address and port number.
225961847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
226061847f8eSopenharmony_ci     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
226161847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
226261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
226361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
226461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
226561847f8eSopenharmony_ci     * @crossplatform
226661847f8eSopenharmony_ci     * @since 10
226761847f8eSopenharmony_ci     */
226861847f8eSopenharmony_ci    connect(options: TCPConnectOptions): Promise<void>;
226961847f8eSopenharmony_ci
227061847f8eSopenharmony_ci    /**
227161847f8eSopenharmony_ci     * Sends data over a TCPSocket connection.
227261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
227361847f8eSopenharmony_ci     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
227461847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
227561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
227661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
227761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
227861847f8eSopenharmony_ci     * @since 7
227961847f8eSopenharmony_ci     */
228061847f8eSopenharmony_ci    /**
228161847f8eSopenharmony_ci     * Sends data over a TCPSocket connection.
228261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
228361847f8eSopenharmony_ci     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
228461847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
228561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
228661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
228761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
228861847f8eSopenharmony_ci     * @crossplatform
228961847f8eSopenharmony_ci     * @since 10
229061847f8eSopenharmony_ci     */
229161847f8eSopenharmony_ci    send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
229261847f8eSopenharmony_ci
229361847f8eSopenharmony_ci    /**
229461847f8eSopenharmony_ci     * Sends data over a TCPSocket connection.
229561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
229661847f8eSopenharmony_ci     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
229761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
229861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
229961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
230061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
230161847f8eSopenharmony_ci     * @since 7
230261847f8eSopenharmony_ci     */
230361847f8eSopenharmony_ci    /**
230461847f8eSopenharmony_ci     * Sends data over a TCPSocket connection.
230561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
230661847f8eSopenharmony_ci     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
230761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
230861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
230961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
231061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
231161847f8eSopenharmony_ci     * @crossplatform
231261847f8eSopenharmony_ci     * @since 10
231361847f8eSopenharmony_ci     */
231461847f8eSopenharmony_ci    send(options: TCPSendOptions): Promise<void>;
231561847f8eSopenharmony_ci
231661847f8eSopenharmony_ci    /**
231761847f8eSopenharmony_ci     * Closes a TCPSocket connection.
231861847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
231961847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
232061847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
232161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
232261847f8eSopenharmony_ci     * @since 7
232361847f8eSopenharmony_ci     */
232461847f8eSopenharmony_ci    /**
232561847f8eSopenharmony_ci     * Closes a TCPSocket connection.
232661847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
232761847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
232861847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
232961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
233061847f8eSopenharmony_ci     * @crossplatform
233161847f8eSopenharmony_ci     * @since 10
233261847f8eSopenharmony_ci     */
233361847f8eSopenharmony_ci    close(callback: AsyncCallback<void>): void;
233461847f8eSopenharmony_ci
233561847f8eSopenharmony_ci    /**
233661847f8eSopenharmony_ci     * Closes a TCPSocket connection.
233761847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
233861847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
233961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
234061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
234161847f8eSopenharmony_ci     * @since 7
234261847f8eSopenharmony_ci     */
234361847f8eSopenharmony_ci    /**
234461847f8eSopenharmony_ci     * Closes a TCPSocket connection.
234561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
234661847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
234761847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
234861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
234961847f8eSopenharmony_ci     * @crossplatform
235061847f8eSopenharmony_ci     * @since 10
235161847f8eSopenharmony_ci     */
235261847f8eSopenharmony_ci    close(): Promise<void>;
235361847f8eSopenharmony_ci
235461847f8eSopenharmony_ci    /**
235561847f8eSopenharmony_ci     * Obtains the peer address of a TCPSocket connection.
235661847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
235761847f8eSopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress. {@link NetAddress}
235861847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
235961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
236061847f8eSopenharmony_ci     * @since 7
236161847f8eSopenharmony_ci     */
236261847f8eSopenharmony_ci    /**
236361847f8eSopenharmony_ci     * Obtains the peer address of a TCPSocket connection.
236461847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
236561847f8eSopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress. {@link NetAddress}
236661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
236761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
236861847f8eSopenharmony_ci     * @crossplatform
236961847f8eSopenharmony_ci     * @since 10
237061847f8eSopenharmony_ci     */
237161847f8eSopenharmony_ci    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
237261847f8eSopenharmony_ci
237361847f8eSopenharmony_ci    /**
237461847f8eSopenharmony_ci     * Obtains the peer address of a TCPSocket connection.
237561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
237661847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
237761847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
237861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
237961847f8eSopenharmony_ci     * @since 7
238061847f8eSopenharmony_ci     */
238161847f8eSopenharmony_ci    /**
238261847f8eSopenharmony_ci     * Obtains the peer address of a TCPSocket connection.
238361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
238461847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
238561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
238661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
238761847f8eSopenharmony_ci     * @crossplatform
238861847f8eSopenharmony_ci     * @since 10
238961847f8eSopenharmony_ci     */
239061847f8eSopenharmony_ci    getRemoteAddress(): Promise<NetAddress>;
239161847f8eSopenharmony_ci
239261847f8eSopenharmony_ci    /**
239361847f8eSopenharmony_ci     * Obtains the status of the TCPSocket connection.
239461847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
239561847f8eSopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}
239661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
239761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
239861847f8eSopenharmony_ci     * @since 7
239961847f8eSopenharmony_ci     */
240061847f8eSopenharmony_ci    /**
240161847f8eSopenharmony_ci     * Obtains the status of the TCPSocket connection.
240261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
240361847f8eSopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}
240461847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
240561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
240661847f8eSopenharmony_ci     * @crossplatform
240761847f8eSopenharmony_ci     * @since 10
240861847f8eSopenharmony_ci     */
240961847f8eSopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
241061847f8eSopenharmony_ci
241161847f8eSopenharmony_ci    /**
241261847f8eSopenharmony_ci     * Obtains the status of the TCPSocket connection.
241361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
241461847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
241561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
241661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
241761847f8eSopenharmony_ci     * @since 7
241861847f8eSopenharmony_ci     */
241961847f8eSopenharmony_ci    /**
242061847f8eSopenharmony_ci     * Obtains the status of the TCPSocket connection.
242161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
242261847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
242361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
242461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
242561847f8eSopenharmony_ci     * @crossplatform
242661847f8eSopenharmony_ci     * @since 10
242761847f8eSopenharmony_ci     */
242861847f8eSopenharmony_ci    getState(): Promise<SocketStateBase>;
242961847f8eSopenharmony_ci
243061847f8eSopenharmony_ci    /**
243161847f8eSopenharmony_ci     * Obtains the file descriptor of the TCPSocket connection.
243261847f8eSopenharmony_ci     * @param { AsyncCallback<number> } callback - The callback returns the file descriptor of the TCPSocket connection.
243361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
243461847f8eSopenharmony_ci     * @since 10
243561847f8eSopenharmony_ci     */
243661847f8eSopenharmony_ci    getSocketFd(callback: AsyncCallback<number>): void;
243761847f8eSopenharmony_ci
243861847f8eSopenharmony_ci    /**
243961847f8eSopenharmony_ci     * Obtains the file descriptor of the TCPSocket connection.
244061847f8eSopenharmony_ci     * @returns { Promise<number> } The promise returns the file descriptor of the TCPSocket connection.
244161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
244261847f8eSopenharmony_ci     * @since 10
244361847f8eSopenharmony_ci     */
244461847f8eSopenharmony_ci    getSocketFd(): Promise<number>;
244561847f8eSopenharmony_ci
244661847f8eSopenharmony_ci    /**
244761847f8eSopenharmony_ci     * Sets other attributes of the TCPSocket connection.
244861847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
244961847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
245061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
245161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
245261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
245361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
245461847f8eSopenharmony_ci     * @since 7
245561847f8eSopenharmony_ci     */
245661847f8eSopenharmony_ci    /**
245761847f8eSopenharmony_ci     * Sets other attributes of the TCPSocket connection.
245861847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
245961847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
246061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
246161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
246261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
246361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
246461847f8eSopenharmony_ci     * @crossplatform
246561847f8eSopenharmony_ci     * @since 10
246661847f8eSopenharmony_ci     */
246761847f8eSopenharmony_ci    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
246861847f8eSopenharmony_ci
246961847f8eSopenharmony_ci    /**
247061847f8eSopenharmony_ci     * Sets other attributes of the TCPSocket connection.
247161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
247261847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
247361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
247461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
247561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
247661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
247761847f8eSopenharmony_ci     * @since 7
247861847f8eSopenharmony_ci     */
247961847f8eSopenharmony_ci    /**
248061847f8eSopenharmony_ci     * Sets other attributes of the TCPSocket connection.
248161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
248261847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
248361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
248461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
248561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
248661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
248761847f8eSopenharmony_ci     * @crossplatform
248861847f8eSopenharmony_ci     * @since 10
248961847f8eSopenharmony_ci     */
249061847f8eSopenharmony_ci    setExtraOptions(options: TCPExtraOptions): Promise<void>;
249161847f8eSopenharmony_ci
249261847f8eSopenharmony_ci    /**
249361847f8eSopenharmony_ci     * Obtains the local address of a TCPSocket connection.
249461847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
249561847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
249661847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
249761847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
249861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
249961847f8eSopenharmony_ci     * @since 12
250061847f8eSopenharmony_ci     */
250161847f8eSopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
250261847f8eSopenharmony_ci
250361847f8eSopenharmony_ci    /**
250461847f8eSopenharmony_ci     * Listens for message receiving events of the TCPSocket connection.
250561847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
250661847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
250761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
250861847f8eSopenharmony_ci     * @since 7
250961847f8eSopenharmony_ci     */
251061847f8eSopenharmony_ci    /**
251161847f8eSopenharmony_ci     * Listens for message receiving events of the TCPSocket connection.
251261847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
251361847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
251461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
251561847f8eSopenharmony_ci     * @crossplatform
251661847f8eSopenharmony_ci     * @since 10
251761847f8eSopenharmony_ci     */
251861847f8eSopenharmony_ci    /**
251961847f8eSopenharmony_ci     * Listens for message receiving events of the TCPSocket connection.
252061847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
252161847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
252261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
252361847f8eSopenharmony_ci     * @crossplatform
252461847f8eSopenharmony_ci     * @since 11
252561847f8eSopenharmony_ci     */
252661847f8eSopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
252761847f8eSopenharmony_ci
252861847f8eSopenharmony_ci    /**
252961847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TCPSocket connection.
253061847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
253161847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
253261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
253361847f8eSopenharmony_ci     * @since 7
253461847f8eSopenharmony_ci     */
253561847f8eSopenharmony_ci    /**
253661847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TCPSocket connection.
253761847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
253861847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
253961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
254061847f8eSopenharmony_ci     * @crossplatform
254161847f8eSopenharmony_ci     * @since 10
254261847f8eSopenharmony_ci     */
254361847f8eSopenharmony_ci    /**
254461847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TCPSocket connection.
254561847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
254661847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
254761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
254861847f8eSopenharmony_ci     * @crossplatform
254961847f8eSopenharmony_ci     * @since 11
255061847f8eSopenharmony_ci     */
255161847f8eSopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
255261847f8eSopenharmony_ci
255361847f8eSopenharmony_ci
255461847f8eSopenharmony_ci    /**
255561847f8eSopenharmony_ci     * Listens for connection or close events of the TCPSocket connection.
255661847f8eSopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
255761847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
255861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
255961847f8eSopenharmony_ci     * @since 7
256061847f8eSopenharmony_ci     */
256161847f8eSopenharmony_ci    /**
256261847f8eSopenharmony_ci     * Listens for connection or close events of the TCPSocket connection.
256361847f8eSopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
256461847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
256561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
256661847f8eSopenharmony_ci     * @crossplatform
256761847f8eSopenharmony_ci     * @since 10
256861847f8eSopenharmony_ci     */
256961847f8eSopenharmony_ci    on(type: 'connect' | 'close', callback: Callback<void>): void;
257061847f8eSopenharmony_ci
257161847f8eSopenharmony_ci    /**
257261847f8eSopenharmony_ci     * Cancels listening for connection or close events of the TCPSocket connection.
257361847f8eSopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
257461847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
257561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
257661847f8eSopenharmony_ci     * @since 7
257761847f8eSopenharmony_ci     */
257861847f8eSopenharmony_ci    /**
257961847f8eSopenharmony_ci     * Cancels listening for connection or close events of the TCPSocket connection.
258061847f8eSopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
258161847f8eSopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
258261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
258361847f8eSopenharmony_ci     * @crossplatform
258461847f8eSopenharmony_ci     * @since 10
258561847f8eSopenharmony_ci     */
258661847f8eSopenharmony_ci    off(type: 'connect' | 'close', callback?: Callback<void>): void;
258761847f8eSopenharmony_ci
258861847f8eSopenharmony_ci    /**
258961847f8eSopenharmony_ci     * Listens for error events of the TCPSocket connection.
259061847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
259161847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
259261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
259361847f8eSopenharmony_ci     * @since 7
259461847f8eSopenharmony_ci     */
259561847f8eSopenharmony_ci    /**
259661847f8eSopenharmony_ci     * Listens for error events of the TCPSocket connection.
259761847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
259861847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
259961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
260061847f8eSopenharmony_ci     * @crossplatform
260161847f8eSopenharmony_ci     * @since 10
260261847f8eSopenharmony_ci     */
260361847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
260461847f8eSopenharmony_ci
260561847f8eSopenharmony_ci    /**
260661847f8eSopenharmony_ci     * Cancels listening for error events of the TCPSocket connection.
260761847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
260861847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
260961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
261061847f8eSopenharmony_ci     * @since 7
261161847f8eSopenharmony_ci     */
261261847f8eSopenharmony_ci    /**
261361847f8eSopenharmony_ci     * Cancels listening for error events of the TCPSocket connection.
261461847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
261561847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
261661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
261761847f8eSopenharmony_ci     * @crossplatform
261861847f8eSopenharmony_ci     * @since 10
261961847f8eSopenharmony_ci     */
262061847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
262161847f8eSopenharmony_ci  }
262261847f8eSopenharmony_ci
262361847f8eSopenharmony_ci  /**
262461847f8eSopenharmony_ci   * Defines a TLSSocket connection.
262561847f8eSopenharmony_ci   * @interface TLSSocket
262661847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
262761847f8eSopenharmony_ci   * @since 9
262861847f8eSopenharmony_ci   */
262961847f8eSopenharmony_ci  /**
263061847f8eSopenharmony_ci   * Defines a TLSSocket connection.
263161847f8eSopenharmony_ci   * @interface TLSSocket
263261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
263361847f8eSopenharmony_ci   * @crossplatform
263461847f8eSopenharmony_ci   * @since 10
263561847f8eSopenharmony_ci   */
263661847f8eSopenharmony_ci  export interface TLSSocket {
263761847f8eSopenharmony_ci    /**
263861847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
263961847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
264061847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
264161847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
264261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
264361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
264461847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
264561847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
264661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
264761847f8eSopenharmony_ci     * @since 9
264861847f8eSopenharmony_ci     */
264961847f8eSopenharmony_ci    /**
265061847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
265161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
265261847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
265361847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
265461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
265561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
265661847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
265761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
265861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
265961847f8eSopenharmony_ci     * @crossplatform
266061847f8eSopenharmony_ci     * @since 10
266161847f8eSopenharmony_ci     */
266261847f8eSopenharmony_ci    bind(address: NetAddress, callback: AsyncCallback<void>): void;
266361847f8eSopenharmony_ci
266461847f8eSopenharmony_ci    /**
266561847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
266661847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
266761847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
266861847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
266961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
267061847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
267161847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
267261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
267361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
267461847f8eSopenharmony_ci     * @since 9
267561847f8eSopenharmony_ci     */
267661847f8eSopenharmony_ci    /**
267761847f8eSopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
267861847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
267961847f8eSopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
268061847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
268161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
268261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
268361847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
268461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
268561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
268661847f8eSopenharmony_ci     * @crossplatform
268761847f8eSopenharmony_ci     * @since 10
268861847f8eSopenharmony_ci     */
268961847f8eSopenharmony_ci    bind(address: NetAddress): Promise<void>;
269061847f8eSopenharmony_ci
269161847f8eSopenharmony_ci    /**
269261847f8eSopenharmony_ci     * Obtains the peer address of a TLSSocket connection.
269361847f8eSopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress.
269461847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
269561847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
269661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
269761847f8eSopenharmony_ci     * @since 9
269861847f8eSopenharmony_ci     */
269961847f8eSopenharmony_ci    /**
270061847f8eSopenharmony_ci     * Obtains the peer address of a TLSSocket connection.
270161847f8eSopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress.
270261847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
270361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
270461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
270561847f8eSopenharmony_ci     * @crossplatform
270661847f8eSopenharmony_ci     * @since 10
270761847f8eSopenharmony_ci     */
270861847f8eSopenharmony_ci    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
270961847f8eSopenharmony_ci
271061847f8eSopenharmony_ci    /**
271161847f8eSopenharmony_ci     * Obtains the peer address of a TLSSocket connection.
271261847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
271361847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
271461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
271561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
271661847f8eSopenharmony_ci     * @since 9
271761847f8eSopenharmony_ci     */
271861847f8eSopenharmony_ci    /**
271961847f8eSopenharmony_ci     * Obtains the peer address of a TLSSocket connection.
272061847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
272161847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
272261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
272361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
272461847f8eSopenharmony_ci     * @crossplatform
272561847f8eSopenharmony_ci     * @since 10
272661847f8eSopenharmony_ci     */
272761847f8eSopenharmony_ci    getRemoteAddress(): Promise<NetAddress>;
272861847f8eSopenharmony_ci
272961847f8eSopenharmony_ci    /**
273061847f8eSopenharmony_ci     * Obtains the status of the TLSSocket connection.
273161847f8eSopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState.
273261847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
273361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
273461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
273561847f8eSopenharmony_ci     * @since 9
273661847f8eSopenharmony_ci     */
273761847f8eSopenharmony_ci    /**
273861847f8eSopenharmony_ci     * Obtains the status of the TLSSocket connection.
273961847f8eSopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState.
274061847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
274161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
274261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
274361847f8eSopenharmony_ci     * @crossplatform
274461847f8eSopenharmony_ci     * @since 10
274561847f8eSopenharmony_ci     */
274661847f8eSopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
274761847f8eSopenharmony_ci
274861847f8eSopenharmony_ci    /**
274961847f8eSopenharmony_ci     * Obtains the status of the TLSSocket connection.
275061847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
275161847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
275261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
275361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
275461847f8eSopenharmony_ci     * @since 9
275561847f8eSopenharmony_ci     */
275661847f8eSopenharmony_ci    /**
275761847f8eSopenharmony_ci     * Obtains the status of the TLSSocket connection.
275861847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
275961847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
276061847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
276161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
276261847f8eSopenharmony_ci     * @crossplatform
276361847f8eSopenharmony_ci     * @since 10
276461847f8eSopenharmony_ci     */
276561847f8eSopenharmony_ci    getState(): Promise<SocketStateBase>;
276661847f8eSopenharmony_ci
276761847f8eSopenharmony_ci    /**
276861847f8eSopenharmony_ci     * Sets other attributes of the TLSSocket connection.
276961847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
277061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
277161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
277261847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
277361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
277461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
277561847f8eSopenharmony_ci     * @since 9
277661847f8eSopenharmony_ci     */
277761847f8eSopenharmony_ci    /**
277861847f8eSopenharmony_ci     * Sets other attributes of the TLSSocket connection.
277961847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
278061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
278161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
278261847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
278361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
278461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
278561847f8eSopenharmony_ci     * @crossplatform
278661847f8eSopenharmony_ci     * @since 10
278761847f8eSopenharmony_ci     */
278861847f8eSopenharmony_ci    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
278961847f8eSopenharmony_ci
279061847f8eSopenharmony_ci    /**
279161847f8eSopenharmony_ci     * Sets other attributes of the TLSSocket connection.
279261847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
279361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
279461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
279561847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
279661847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
279761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
279861847f8eSopenharmony_ci     * @since 9
279961847f8eSopenharmony_ci     */
280061847f8eSopenharmony_ci    /**
280161847f8eSopenharmony_ci     * Sets other attributes of the TLSSocket connection.
280261847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
280361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
280461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
280561847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
280661847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
280761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
280861847f8eSopenharmony_ci     * @crossplatform
280961847f8eSopenharmony_ci     * @since 10
281061847f8eSopenharmony_ci     */
281161847f8eSopenharmony_ci    setExtraOptions(options: TCPExtraOptions): Promise<void>;
281261847f8eSopenharmony_ci
281361847f8eSopenharmony_ci    /**
281461847f8eSopenharmony_ci     * Obtains the local address of a TLSSocket connection.
281561847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
281661847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
281761847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
281861847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
281961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
282061847f8eSopenharmony_ci     * @since 12
282161847f8eSopenharmony_ci     */
282261847f8eSopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
282361847f8eSopenharmony_ci
282461847f8eSopenharmony_ci    /**
282561847f8eSopenharmony_ci     * Listens for message receiving events of the TLSSocket connection.
282661847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
282761847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
282861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
282961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
283061847f8eSopenharmony_ci     * @since 9
283161847f8eSopenharmony_ci     */
283261847f8eSopenharmony_ci    /**
283361847f8eSopenharmony_ci     * Listens for message receiving events of the TLSSocket connection.
283461847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
283561847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
283661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
283761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
283861847f8eSopenharmony_ci     * @crossplatform
283961847f8eSopenharmony_ci     * @since 10
284061847f8eSopenharmony_ci     */
284161847f8eSopenharmony_ci    /**
284261847f8eSopenharmony_ci     * Listens for message receiving events of the TLSSocket connection.
284361847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
284461847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
284561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
284661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
284761847f8eSopenharmony_ci     * @crossplatform
284861847f8eSopenharmony_ci     * @since 11
284961847f8eSopenharmony_ci     */
285061847f8eSopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
285161847f8eSopenharmony_ci
285261847f8eSopenharmony_ci    /**
285361847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TLSSocket connection.
285461847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
285561847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
285661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
285761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
285861847f8eSopenharmony_ci     * @since 9
285961847f8eSopenharmony_ci     */
286061847f8eSopenharmony_ci    /**
286161847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TLSSocket connection.
286261847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
286361847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
286461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
286561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
286661847f8eSopenharmony_ci     * @crossplatform
286761847f8eSopenharmony_ci     * @since 10
286861847f8eSopenharmony_ci     */
286961847f8eSopenharmony_ci    /**
287061847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TLSSocket connection.
287161847f8eSopenharmony_ci     * @param { 'message' } type Indicates Event name.
287261847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
287361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
287461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
287561847f8eSopenharmony_ci     * @crossplatform
287661847f8eSopenharmony_ci     * @since 11
287761847f8eSopenharmony_ci     */
287861847f8eSopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
287961847f8eSopenharmony_ci
288061847f8eSopenharmony_ci    /**
288161847f8eSopenharmony_ci     * Listens for connection or close events of the TLSSocket connection.
288261847f8eSopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
288361847f8eSopenharmony_ci     * @param {Callback<void> } callback - the callback used to return the result.
288461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
288561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
288661847f8eSopenharmony_ci     * @since 9
288761847f8eSopenharmony_ci     */
288861847f8eSopenharmony_ci    /**
288961847f8eSopenharmony_ci     * Listens for connection or close events of the TLSSocket connection.
289061847f8eSopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
289161847f8eSopenharmony_ci     * @param {Callback<void> } callback - the callback used to return the result.
289261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
289361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
289461847f8eSopenharmony_ci     * @crossplatform
289561847f8eSopenharmony_ci     * @since 10
289661847f8eSopenharmony_ci     */
289761847f8eSopenharmony_ci    on(type: 'connect' | 'close', callback: Callback<void>): void;
289861847f8eSopenharmony_ci
289961847f8eSopenharmony_ci    /**
290061847f8eSopenharmony_ci     * Cancels listening for connection or close events of the TLSSocket connection.
290161847f8eSopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
290261847f8eSopenharmony_ci     * @param {Callback<void> } callback - the callback used to return the result.
290361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
290461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
290561847f8eSopenharmony_ci     * @since 9
290661847f8eSopenharmony_ci     */
290761847f8eSopenharmony_ci    /**
290861847f8eSopenharmony_ci     * Cancels listening for connection or close events of the TLSSocket connection.
290961847f8eSopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
291061847f8eSopenharmony_ci     * @param {Callback<void> } callback - the callback used to return the result.
291161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
291261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
291361847f8eSopenharmony_ci     * @crossplatform
291461847f8eSopenharmony_ci     * @since 10
291561847f8eSopenharmony_ci     */
291661847f8eSopenharmony_ci    off(type: 'connect' | 'close', callback?: Callback<void>): void;
291761847f8eSopenharmony_ci
291861847f8eSopenharmony_ci    /**
291961847f8eSopenharmony_ci     * Listens for error events of the TLSSocket connection.
292061847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
292161847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
292261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
292361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
292461847f8eSopenharmony_ci     * @since 9
292561847f8eSopenharmony_ci     */
292661847f8eSopenharmony_ci    /**
292761847f8eSopenharmony_ci     * Listens for error events of the TLSSocket connection.
292861847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
292961847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
293061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
293161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
293261847f8eSopenharmony_ci     * @crossplatform
293361847f8eSopenharmony_ci     * @since 10
293461847f8eSopenharmony_ci     */
293561847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
293661847f8eSopenharmony_ci
293761847f8eSopenharmony_ci    /**
293861847f8eSopenharmony_ci     * Cancels listening for error events of the TLSSocket connection.
293961847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
294061847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
294161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
294261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
294361847f8eSopenharmony_ci     * @since 9
294461847f8eSopenharmony_ci     */
294561847f8eSopenharmony_ci    /**
294661847f8eSopenharmony_ci     * Cancels listening for error events of the TLSSocket connection.
294761847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
294861847f8eSopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
294961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
295061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
295161847f8eSopenharmony_ci     * @crossplatform
295261847f8eSopenharmony_ci     * @since 10
295361847f8eSopenharmony_ci     */
295461847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
295561847f8eSopenharmony_ci
295661847f8eSopenharmony_ci    /**
295761847f8eSopenharmony_ci     * Returns an object representing a local certificate.
295861847f8eSopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getCertificate.
295961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
296061847f8eSopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
296161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
296261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
296361847f8eSopenharmony_ci     * @since 9
296461847f8eSopenharmony_ci     */
296561847f8eSopenharmony_ci    /**
296661847f8eSopenharmony_ci     * Returns an object representing a local certificate.
296761847f8eSopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getCertificate.
296861847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
296961847f8eSopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
297061847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
297161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
297261847f8eSopenharmony_ci     * @crossplatform
297361847f8eSopenharmony_ci     * @since 10
297461847f8eSopenharmony_ci     */
297561847f8eSopenharmony_ci    getCertificate(callback: AsyncCallback<X509CertRawData>): void;
297661847f8eSopenharmony_ci
297761847f8eSopenharmony_ci    /**
297861847f8eSopenharmony_ci     * Returns an object representing a local certificate.
297961847f8eSopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
298061847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
298161847f8eSopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
298261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
298361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
298461847f8eSopenharmony_ci     * @since 9
298561847f8eSopenharmony_ci     */
298661847f8eSopenharmony_ci    /**
298761847f8eSopenharmony_ci     * Returns an object representing a local certificate.
298861847f8eSopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
298961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
299061847f8eSopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
299161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
299261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
299361847f8eSopenharmony_ci     * @crossplatform
299461847f8eSopenharmony_ci     * @since 10
299561847f8eSopenharmony_ci     */
299661847f8eSopenharmony_ci    getCertificate(): Promise<X509CertRawData>;
299761847f8eSopenharmony_ci
299861847f8eSopenharmony_ci    /**
299961847f8eSopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
300061847f8eSopenharmony_ci     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
300161847f8eSopenharmony_ci     * It only contains the peer's certificate.
300261847f8eSopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getRemoteCertificate.
300361847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
300461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
300561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
300661847f8eSopenharmony_ci     * @since 9
300761847f8eSopenharmony_ci     */
300861847f8eSopenharmony_ci    /**
300961847f8eSopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
301061847f8eSopenharmony_ci     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
301161847f8eSopenharmony_ci     * It only contains the peer's certificate.
301261847f8eSopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getRemoteCertificate.
301361847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
301461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
301561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
301661847f8eSopenharmony_ci     * @crossplatform
301761847f8eSopenharmony_ci     * @since 10
301861847f8eSopenharmony_ci     */
301961847f8eSopenharmony_ci    getRemoteCertificate(callback: AsyncCallback<X509CertRawData>): void;
302061847f8eSopenharmony_ci
302161847f8eSopenharmony_ci    /**
302261847f8eSopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
302361847f8eSopenharmony_ci     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
302461847f8eSopenharmony_ci     * It only contains the peer's certificate.
302561847f8eSopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
302661847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
302761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
302861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
302961847f8eSopenharmony_ci     * @since 9
303061847f8eSopenharmony_ci     */
303161847f8eSopenharmony_ci    /**
303261847f8eSopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
303361847f8eSopenharmony_ci     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
303461847f8eSopenharmony_ci     * It only contains the peer's certificate.
303561847f8eSopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
303661847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
303761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
303861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
303961847f8eSopenharmony_ci     * @crossplatform
304061847f8eSopenharmony_ci     * @since 10
304161847f8eSopenharmony_ci     */
304261847f8eSopenharmony_ci    getRemoteCertificate(): Promise<X509CertRawData>;
304361847f8eSopenharmony_ci
304461847f8eSopenharmony_ci    /**
304561847f8eSopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
304661847f8eSopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
304761847f8eSopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
304861847f8eSopenharmony_ci     * @param { AsyncCallback<string> } callback - the callback of getProtocol.
304961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
305061847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
305161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
305261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
305361847f8eSopenharmony_ci     * @since 9
305461847f8eSopenharmony_ci     */
305561847f8eSopenharmony_ci    /**
305661847f8eSopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
305761847f8eSopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
305861847f8eSopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
305961847f8eSopenharmony_ci     * @param { AsyncCallback<string> } callback - the callback of getProtocol.
306061847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
306161847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
306261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
306361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
306461847f8eSopenharmony_ci     * @crossplatform
306561847f8eSopenharmony_ci     * @since 10
306661847f8eSopenharmony_ci     */
306761847f8eSopenharmony_ci    getProtocol(callback: AsyncCallback<string>): void;
306861847f8eSopenharmony_ci
306961847f8eSopenharmony_ci    /**
307061847f8eSopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
307161847f8eSopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
307261847f8eSopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
307361847f8eSopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
307461847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
307561847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
307661847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
307761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
307861847f8eSopenharmony_ci     * @since 9
307961847f8eSopenharmony_ci     */
308061847f8eSopenharmony_ci    /**
308161847f8eSopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
308261847f8eSopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
308361847f8eSopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
308461847f8eSopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
308561847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
308661847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
308761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
308861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
308961847f8eSopenharmony_ci     * @crossplatform
309061847f8eSopenharmony_ci     * @since 10
309161847f8eSopenharmony_ci     */
309261847f8eSopenharmony_ci    getProtocol(): Promise<string>;
309361847f8eSopenharmony_ci
309461847f8eSopenharmony_ci    /**
309561847f8eSopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
309661847f8eSopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
309761847f8eSopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - the callback of getCipherSuite.
309861847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
309961847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
310061847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
310161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
310261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
310361847f8eSopenharmony_ci     * @since 9
310461847f8eSopenharmony_ci     */
310561847f8eSopenharmony_ci    /**
310661847f8eSopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
310761847f8eSopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
310861847f8eSopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - the callback of getCipherSuite.
310961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
311061847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
311161847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
311261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
311361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
311461847f8eSopenharmony_ci     * @crossplatform
311561847f8eSopenharmony_ci     * @since 10
311661847f8eSopenharmony_ci     */
311761847f8eSopenharmony_ci    getCipherSuite(callback: AsyncCallback<Array<string>>): void;
311861847f8eSopenharmony_ci
311961847f8eSopenharmony_ci    /**
312061847f8eSopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
312161847f8eSopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
312261847f8eSopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.
312361847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
312461847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
312561847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
312661847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
312761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
312861847f8eSopenharmony_ci     * @since 9
312961847f8eSopenharmony_ci     */
313061847f8eSopenharmony_ci    /**
313161847f8eSopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
313261847f8eSopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
313361847f8eSopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.
313461847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
313561847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
313661847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
313761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
313861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
313961847f8eSopenharmony_ci     * @crossplatform
314061847f8eSopenharmony_ci     * @since 10
314161847f8eSopenharmony_ci     */
314261847f8eSopenharmony_ci    getCipherSuite(): Promise<Array<string>>;
314361847f8eSopenharmony_ci
314461847f8eSopenharmony_ci    /**
314561847f8eSopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
314661847f8eSopenharmony_ci     * in descending order of priority.</p>
314761847f8eSopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - the callback of getSignatureAlgorithms.@see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html
314861847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
314961847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
315061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
315161847f8eSopenharmony_ci     * @since 9
315261847f8eSopenharmony_ci     */
315361847f8eSopenharmony_ci    /**
315461847f8eSopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
315561847f8eSopenharmony_ci     * in descending order of priority.</p>
315661847f8eSopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - the callback of getSignatureAlgorithms.@see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html
315761847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
315861847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
315961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
316061847f8eSopenharmony_ci     * @crossplatform
316161847f8eSopenharmony_ci     * @since 10
316261847f8eSopenharmony_ci     */
316361847f8eSopenharmony_ci    getSignatureAlgorithms(callback: AsyncCallback<Array<string>>): void;
316461847f8eSopenharmony_ci
316561847f8eSopenharmony_ci    /**
316661847f8eSopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
316761847f8eSopenharmony_ci     * in descending order of priority.</p>
316861847f8eSopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.@see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html
316961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
317061847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
317161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
317261847f8eSopenharmony_ci     * @since 9
317361847f8eSopenharmony_ci     */
317461847f8eSopenharmony_ci    /**
317561847f8eSopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
317661847f8eSopenharmony_ci     * in descending order of priority.</p>
317761847f8eSopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.@see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html
317861847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
317961847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
318061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
318161847f8eSopenharmony_ci     * @crossplatform
318261847f8eSopenharmony_ci     * @since 10
318361847f8eSopenharmony_ci     */
318461847f8eSopenharmony_ci    getSignatureAlgorithms(): Promise<Array<string>>;
318561847f8eSopenharmony_ci
318661847f8eSopenharmony_ci    /**
318761847f8eSopenharmony_ci     * Sets up a connection to the specified IP address and port number.
318861847f8eSopenharmony_ci     * Only TCP is supported.
318961847f8eSopenharmony_ci     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
319061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of connect.
319161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
319261847f8eSopenharmony_ci     * @throws { BusinessError } 2303104 - Interrupted system call.
319361847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
319461847f8eSopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
319561847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
319661847f8eSopenharmony_ci     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
319761847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
319861847f8eSopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
319961847f8eSopenharmony_ci     * @throws { BusinessError } 2303210 - Connection timed out.
320061847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
320161847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
320261847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
320361847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
320461847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
320561847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
320661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
320761847f8eSopenharmony_ci     * @since 9
320861847f8eSopenharmony_ci     */
320961847f8eSopenharmony_ci    /**
321061847f8eSopenharmony_ci     * Sets up a connection to the specified IP address and port number.
321161847f8eSopenharmony_ci     * Only TCP is supported.
321261847f8eSopenharmony_ci     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
321361847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of connect.
321461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
321561847f8eSopenharmony_ci     * @throws { BusinessError } 2303104 - Interrupted system call.
321661847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
321761847f8eSopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
321861847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
321961847f8eSopenharmony_ci     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
322061847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
322161847f8eSopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
322261847f8eSopenharmony_ci     * @throws { BusinessError } 2303210 - Connection timed out.
322361847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
322461847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
322561847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
322661847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
322761847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
322861847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
322961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
323061847f8eSopenharmony_ci     * @crossplatform
323161847f8eSopenharmony_ci     * @since 10
323261847f8eSopenharmony_ci     */
323361847f8eSopenharmony_ci    connect(options: TLSConnectOptions, callback: AsyncCallback<void>): void;
323461847f8eSopenharmony_ci
323561847f8eSopenharmony_ci    /**
323661847f8eSopenharmony_ci     * Sets up a connection to the specified IP address and port number.
323761847f8eSopenharmony_ci     * Only TCP is supported.
323861847f8eSopenharmony_ci     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
323961847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
324061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
324161847f8eSopenharmony_ci     * @throws { BusinessError } 2303104 - Interrupted system call.
324261847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
324361847f8eSopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
324461847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
324561847f8eSopenharmony_ci     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
324661847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
324761847f8eSopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
324861847f8eSopenharmony_ci     * @throws { BusinessError } 2303210 - Connection timed out.
324961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
325061847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
325161847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
325261847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
325361847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
325461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
325561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
325661847f8eSopenharmony_ci     * @since 9
325761847f8eSopenharmony_ci     */
325861847f8eSopenharmony_ci    /**
325961847f8eSopenharmony_ci     * Sets up a connection to the specified IP address and port number.
326061847f8eSopenharmony_ci     * Only TCP is supported.
326161847f8eSopenharmony_ci     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
326261847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
326361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
326461847f8eSopenharmony_ci     * @throws { BusinessError } 2303104 - Interrupted system call.
326561847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
326661847f8eSopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
326761847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
326861847f8eSopenharmony_ci     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
326961847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
327061847f8eSopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
327161847f8eSopenharmony_ci     * @throws { BusinessError } 2303210 - Connection timed out.
327261847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
327361847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
327461847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
327561847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
327661847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
327761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
327861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
327961847f8eSopenharmony_ci     * @crossplatform
328061847f8eSopenharmony_ci     * @since 10
328161847f8eSopenharmony_ci     */
328261847f8eSopenharmony_ci    connect(options: TLSConnectOptions): Promise<void>;
328361847f8eSopenharmony_ci
328461847f8eSopenharmony_ci    /**
328561847f8eSopenharmony_ci     * Sends data over a TLSSocket connection.
328661847f8eSopenharmony_ci     * @param { string } data - Parameters for sending data {@link string}.
328761847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
328861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
328961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
329061847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
329161847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
329261847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
329361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
329461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
329561847f8eSopenharmony_ci     * @since 9
329661847f8eSopenharmony_ci     */
329761847f8eSopenharmony_ci    /**
329861847f8eSopenharmony_ci     * Sends data over a TLSSocket connection.
329961847f8eSopenharmony_ci     * @param { string } data - Parameters for sending data {@link string}.
330061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
330161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
330261847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
330361847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
330461847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
330561847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
330661847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
330761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
330861847f8eSopenharmony_ci     * @crossplatform
330961847f8eSopenharmony_ci     * @since 10
331061847f8eSopenharmony_ci     */
331161847f8eSopenharmony_ci    /**
331261847f8eSopenharmony_ci     * Sends data over a TLSSocket connection.
331361847f8eSopenharmony_ci     * @param { string | ArrayBuffer } data - Parameters for sending data.
331461847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
331561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
331661847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
331761847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
331861847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
331961847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
332061847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
332161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
332261847f8eSopenharmony_ci     * @crossplatform
332361847f8eSopenharmony_ci     * @since 12
332461847f8eSopenharmony_ci     */
332561847f8eSopenharmony_ci    send(data: string | ArrayBuffer, callback: AsyncCallback<void>): void;
332661847f8eSopenharmony_ci
332761847f8eSopenharmony_ci    /**
332861847f8eSopenharmony_ci     * Sends data over a TLSSocket connection.
332961847f8eSopenharmony_ci     * @param { string } data - Parameters for sending data {@link string}.
333061847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
333161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
333261847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
333361847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
333461847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
333561847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
333661847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
333761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
333861847f8eSopenharmony_ci     * @since 9
333961847f8eSopenharmony_ci     */
334061847f8eSopenharmony_ci    /**
334161847f8eSopenharmony_ci     * Sends data over a TLSSocket connection.
334261847f8eSopenharmony_ci     * @param { string } data - Parameters for sending data {@link string}.
334361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
334461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
334561847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
334661847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
334761847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
334861847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
334961847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
335061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
335161847f8eSopenharmony_ci     * @crossplatform
335261847f8eSopenharmony_ci     * @since 10
335361847f8eSopenharmony_ci     */
335461847f8eSopenharmony_ci    /**
335561847f8eSopenharmony_ci     * Sends data over a TLSSocket connection.
335661847f8eSopenharmony_ci     * @param { string | ArrayBuffer } data - Parameters for sending data.
335761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
335861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
335961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
336061847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
336161847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
336261847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
336361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
336461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
336561847f8eSopenharmony_ci     * @crossplatform
336661847f8eSopenharmony_ci     * @since 12
336761847f8eSopenharmony_ci     */
336861847f8eSopenharmony_ci    send(data: string | ArrayBuffer): Promise<void>;
336961847f8eSopenharmony_ci
337061847f8eSopenharmony_ci    /**
337161847f8eSopenharmony_ci     * Closes a TLSSocket connection
337261847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
337361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
337461847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
337561847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
337661847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
337761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
337861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
337961847f8eSopenharmony_ci     * @since 9
338061847f8eSopenharmony_ci     */
338161847f8eSopenharmony_ci    /**
338261847f8eSopenharmony_ci     * Closes a TLSSocket connection
338361847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
338461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
338561847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
338661847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
338761847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
338861847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
338961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
339061847f8eSopenharmony_ci     * @crossplatform
339161847f8eSopenharmony_ci     * @since 10
339261847f8eSopenharmony_ci     */
339361847f8eSopenharmony_ci    close(callback: AsyncCallback<void>): void;
339461847f8eSopenharmony_ci
339561847f8eSopenharmony_ci    /**
339661847f8eSopenharmony_ci     * Closes a TLSSocket connection
339761847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
339861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
339961847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
340061847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
340161847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
340261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
340361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
340461847f8eSopenharmony_ci     * @since 9
340561847f8eSopenharmony_ci     */
340661847f8eSopenharmony_ci    /**
340761847f8eSopenharmony_ci     * Closes a TLSSocket connection
340861847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
340961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
341061847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
341161847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
341261847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
341361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
341461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
341561847f8eSopenharmony_ci     * @crossplatform
341661847f8eSopenharmony_ci     * @since 10
341761847f8eSopenharmony_ci     */
341861847f8eSopenharmony_ci    close(): Promise<void>;
341961847f8eSopenharmony_ci  }
342061847f8eSopenharmony_ci
342161847f8eSopenharmony_ci  /**
342261847f8eSopenharmony_ci   * Defines TLS security options. The CA certificate is mandatory, and other parameters are optional.
342361847f8eSopenharmony_ci   * @interface TLSSecureOptions
342461847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
342561847f8eSopenharmony_ci   * @since 9
342661847f8eSopenharmony_ci   */
342761847f8eSopenharmony_ci  /**
342861847f8eSopenharmony_ci   * Defines TLS security options. The CA certificate is mandatory, and other parameters are optional.
342961847f8eSopenharmony_ci   * @interface TLSSecureOptions
343061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
343161847f8eSopenharmony_ci   * @crossplatform
343261847f8eSopenharmony_ci   * @since 10
343361847f8eSopenharmony_ci   */
343461847f8eSopenharmony_ci  export interface TLSSecureOptions {
343561847f8eSopenharmony_ci    /**
343661847f8eSopenharmony_ci     * Certificate used to verify the identity of the server
343761847f8eSopenharmony_ci     * @type {string | Array<string>}
343861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
343961847f8eSopenharmony_ci     * @since 9
344061847f8eSopenharmony_ci     */
344161847f8eSopenharmony_ci    /**
344261847f8eSopenharmony_ci     * Certificate used to verify the identity of the server.
344361847f8eSopenharmony_ci     * @type {string | Array<string>}
344461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
344561847f8eSopenharmony_ci     * @crossplatform
344661847f8eSopenharmony_ci     * @since 10
344761847f8eSopenharmony_ci     */
344861847f8eSopenharmony_ci    /**
344961847f8eSopenharmony_ci     * Certificate used to verify the identity of the server, if it is not set, use system ca.
345061847f8eSopenharmony_ci     * @type {?(string | Array<string>)}
345161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
345261847f8eSopenharmony_ci     * @crossplatform
345361847f8eSopenharmony_ci     * @since 12
345461847f8eSopenharmony_ci     */
345561847f8eSopenharmony_ci    ca?: string | Array<string>;
345661847f8eSopenharmony_ci
345761847f8eSopenharmony_ci    /**
345861847f8eSopenharmony_ci     * Certificate proving the identity of the client
345961847f8eSopenharmony_ci     * @type {?string}
346061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
346161847f8eSopenharmony_ci     * @since 9
346261847f8eSopenharmony_ci     */
346361847f8eSopenharmony_ci    /**
346461847f8eSopenharmony_ci     * Certificate proving the identity of the client
346561847f8eSopenharmony_ci     * @type {?string}
346661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
346761847f8eSopenharmony_ci     * @crossplatform
346861847f8eSopenharmony_ci     * @since 10
346961847f8eSopenharmony_ci     */
347061847f8eSopenharmony_ci    cert?: string;
347161847f8eSopenharmony_ci
347261847f8eSopenharmony_ci    /**
347361847f8eSopenharmony_ci     * Private key of client certificate
347461847f8eSopenharmony_ci     * @type {?string}
347561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
347661847f8eSopenharmony_ci     * @since 9
347761847f8eSopenharmony_ci     */
347861847f8eSopenharmony_ci    /**
347961847f8eSopenharmony_ci     * Private key of client certificate
348061847f8eSopenharmony_ci     * @type {?string}
348161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
348261847f8eSopenharmony_ci     * @crossplatform
348361847f8eSopenharmony_ci     * @since 10
348461847f8eSopenharmony_ci     */
348561847f8eSopenharmony_ci    key?: string;
348661847f8eSopenharmony_ci
348761847f8eSopenharmony_ci    /**
348861847f8eSopenharmony_ci     * Password of the private key
348961847f8eSopenharmony_ci     * @type {?string}
349061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
349161847f8eSopenharmony_ci     * @since 9
349261847f8eSopenharmony_ci     */
349361847f8eSopenharmony_ci    /**
349461847f8eSopenharmony_ci     * Password of the private key
349561847f8eSopenharmony_ci     * @type {?string}
349661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
349761847f8eSopenharmony_ci     * @crossplatform
349861847f8eSopenharmony_ci     * @since 10
349961847f8eSopenharmony_ci     */
350061847f8eSopenharmony_ci    password?: string;
350161847f8eSopenharmony_ci
350261847f8eSopenharmony_ci    /**
350361847f8eSopenharmony_ci     * TLS protocol version
350461847f8eSopenharmony_ci     * @type {?Protocol | Array<Protocol>}
350561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
350661847f8eSopenharmony_ci     * @since 9
350761847f8eSopenharmony_ci     */
350861847f8eSopenharmony_ci    /**
350961847f8eSopenharmony_ci     * TLS protocol version
351061847f8eSopenharmony_ci     * @type {?(Protocol | Array<Protocol>)}
351161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
351261847f8eSopenharmony_ci     * @crossplatform
351361847f8eSopenharmony_ci     * @since 10
351461847f8eSopenharmony_ci     */
351561847f8eSopenharmony_ci    protocols?: Protocol | Array<Protocol>;
351661847f8eSopenharmony_ci
351761847f8eSopenharmony_ci    /**
351861847f8eSopenharmony_ci     * default is false, use local cipher.
351961847f8eSopenharmony_ci     * @type {?boolean}
352061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
352161847f8eSopenharmony_ci     * @since 9
352261847f8eSopenharmony_ci     */
352361847f8eSopenharmony_ci    /**
352461847f8eSopenharmony_ci     * default is false, use local cipher.
352561847f8eSopenharmony_ci     * @type {?boolean}
352661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
352761847f8eSopenharmony_ci     * @crossplatform
352861847f8eSopenharmony_ci     * @since 10
352961847f8eSopenharmony_ci     */
353061847f8eSopenharmony_ci    useRemoteCipherPrefer?: boolean;
353161847f8eSopenharmony_ci
353261847f8eSopenharmony_ci    /**
353361847f8eSopenharmony_ci     * <P>Supported signature algorithms. This string can contain summary algorithms(SHA256,MD5,etc),Public key algorithm(RSA-PSS,ECDSA,etc),
353461847f8eSopenharmony_ci     * Combination of the two(For example 'RSA+SHA384') or TLS v1.3 Scheme name(For example  rsa_pss_pss_sha512)</P>
353561847f8eSopenharmony_ci     * @type {?string}
353661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
353761847f8eSopenharmony_ci     * @since 9
353861847f8eSopenharmony_ci     */
353961847f8eSopenharmony_ci    /**
354061847f8eSopenharmony_ci     * <P>Supported signature algorithms. This string can contain summary algorithms(SHA256,MD5,etc),Public key algorithm(RSA-PSS,ECDSA,etc),
354161847f8eSopenharmony_ci     * Combination of the two(For example 'RSA+SHA384') or TLS v1.3 Scheme name(For example  rsa_pss_pss_sha512)</P>
354261847f8eSopenharmony_ci     * @type {?string}
354361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
354461847f8eSopenharmony_ci     * @crossplatform
354561847f8eSopenharmony_ci     * @since 10
354661847f8eSopenharmony_ci     */
354761847f8eSopenharmony_ci    signatureAlgorithms?: string;
354861847f8eSopenharmony_ci
354961847f8eSopenharmony_ci    /**
355061847f8eSopenharmony_ci     * Crypto suite specification
355161847f8eSopenharmony_ci     * @type {?string}
355261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
355361847f8eSopenharmony_ci     * @since 9
355461847f8eSopenharmony_ci     */
355561847f8eSopenharmony_ci    /**
355661847f8eSopenharmony_ci     * Crypto suite specification
355761847f8eSopenharmony_ci     * @type {?string}
355861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
355961847f8eSopenharmony_ci     * @crossplatform
356061847f8eSopenharmony_ci     * @since 10
356161847f8eSopenharmony_ci     */
356261847f8eSopenharmony_ci    cipherSuite?: string;
356361847f8eSopenharmony_ci
356461847f8eSopenharmony_ci    /**
356561847f8eSopenharmony_ci     * Used to set up bidirectional authentication. The default value is false.
356661847f8eSopenharmony_ci     * @type {?boolean}
356761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
356861847f8eSopenharmony_ci     * @since 12
356961847f8eSopenharmony_ci     */
357061847f8eSopenharmony_ci    isBidirectionalAuthentication?: boolean;
357161847f8eSopenharmony_ci  }
357261847f8eSopenharmony_ci
357361847f8eSopenharmony_ci  /**
357461847f8eSopenharmony_ci   * Defines TLS connection options.
357561847f8eSopenharmony_ci   * @interface TLSConnectOptions
357661847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
357761847f8eSopenharmony_ci   * @since 9
357861847f8eSopenharmony_ci   */
357961847f8eSopenharmony_ci  /**
358061847f8eSopenharmony_ci   * Defines TLS connection options.
358161847f8eSopenharmony_ci   * @interface TLSConnectOptions
358261847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
358361847f8eSopenharmony_ci   * @crossplatform
358461847f8eSopenharmony_ci   * @since 10
358561847f8eSopenharmony_ci   */
358661847f8eSopenharmony_ci  export interface TLSConnectOptions {
358761847f8eSopenharmony_ci    /**
358861847f8eSopenharmony_ci     * Gateway address.
358961847f8eSopenharmony_ci     * @type {NetAddress}
359061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
359161847f8eSopenharmony_ci     * @since 9
359261847f8eSopenharmony_ci     */
359361847f8eSopenharmony_ci    /**
359461847f8eSopenharmony_ci     * Gateway address.
359561847f8eSopenharmony_ci     * @type {NetAddress}
359661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
359761847f8eSopenharmony_ci     * @crossplatform
359861847f8eSopenharmony_ci     * @since 10
359961847f8eSopenharmony_ci     */
360061847f8eSopenharmony_ci    address: NetAddress;
360161847f8eSopenharmony_ci
360261847f8eSopenharmony_ci    /**
360361847f8eSopenharmony_ci     * Protocol http2TLS security related operations.
360461847f8eSopenharmony_ci     * @type {TLSSecureOptions}
360561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
360661847f8eSopenharmony_ci     * @since 9
360761847f8eSopenharmony_ci     */
360861847f8eSopenharmony_ci    /**
360961847f8eSopenharmony_ci     * Protocol http2TLS security related operations.
361061847f8eSopenharmony_ci     * @type {TLSSecureOptions}
361161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
361261847f8eSopenharmony_ci     * @crossplatform
361361847f8eSopenharmony_ci     * @since 10
361461847f8eSopenharmony_ci     */
361561847f8eSopenharmony_ci    secureOptions: TLSSecureOptions;
361661847f8eSopenharmony_ci
361761847f8eSopenharmony_ci    /**
361861847f8eSopenharmony_ci     * Application layer protocol negotiation extension, such as "spdy/1", "http/1.1", "h2"
361961847f8eSopenharmony_ci     * @type {?Array<string>}
362061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
362161847f8eSopenharmony_ci     * @since 9
362261847f8eSopenharmony_ci     */
362361847f8eSopenharmony_ci    /**
362461847f8eSopenharmony_ci     * Application layer protocol negotiation extension, such as "spdy/1", "http/1.1", "h2"
362561847f8eSopenharmony_ci     * @type {?Array<string>}
362661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
362761847f8eSopenharmony_ci     * @crossplatform
362861847f8eSopenharmony_ci     * @since 10
362961847f8eSopenharmony_ci     */
363061847f8eSopenharmony_ci    ALPNProtocols?: Array<string>;
363161847f8eSopenharmony_ci
363261847f8eSopenharmony_ci    /**
363361847f8eSopenharmony_ci     * Skip identity verification for remote servers. The default value is false.
363461847f8eSopenharmony_ci     * @type {?boolean}
363561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
363661847f8eSopenharmony_ci     * @since 12
363761847f8eSopenharmony_ci     */
363861847f8eSopenharmony_ci    skipRemoteValidation?: boolean;
363961847f8eSopenharmony_ci  }
364061847f8eSopenharmony_ci
364161847f8eSopenharmony_ci  /**
364261847f8eSopenharmony_ci   * Enumerates TLS protocol versions.
364361847f8eSopenharmony_ci   * @enum {string}
364461847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
364561847f8eSopenharmony_ci   * @since 9
364661847f8eSopenharmony_ci   */
364761847f8eSopenharmony_ci  /**
364861847f8eSopenharmony_ci   * Enumerates TLS protocol versions.
364961847f8eSopenharmony_ci   * @enum {string}
365061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
365161847f8eSopenharmony_ci   * @crossplatform
365261847f8eSopenharmony_ci   * @since 10
365361847f8eSopenharmony_ci   */
365461847f8eSopenharmony_ci  export enum Protocol {
365561847f8eSopenharmony_ci    /**
365661847f8eSopenharmony_ci     * Use TLSv1.2 protocol for communication.
365761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
365861847f8eSopenharmony_ci     * @since 9
365961847f8eSopenharmony_ci     */
366061847f8eSopenharmony_ci    /**
366161847f8eSopenharmony_ci     * Use TLSv1.2 protocol for communication.
366261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
366361847f8eSopenharmony_ci     * @crossplatform
366461847f8eSopenharmony_ci     * @since 10
366561847f8eSopenharmony_ci     */
366661847f8eSopenharmony_ci    TLSv12 = "TLSv1.2",
366761847f8eSopenharmony_ci
366861847f8eSopenharmony_ci    /**
366961847f8eSopenharmony_ci     * Use TLSv1.3 protocol for communication.
367061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
367161847f8eSopenharmony_ci     * @since 9
367261847f8eSopenharmony_ci     */
367361847f8eSopenharmony_ci    /**
367461847f8eSopenharmony_ci     * Use TLSv1.3 protocol for communication.
367561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
367661847f8eSopenharmony_ci     * @crossplatform
367761847f8eSopenharmony_ci     * @since 10
367861847f8eSopenharmony_ci     */
367961847f8eSopenharmony_ci    TLSv13 = "TLSv1.3"
368061847f8eSopenharmony_ci  }
368161847f8eSopenharmony_ci
368261847f8eSopenharmony_ci  /**
368361847f8eSopenharmony_ci   * Defines the connection of the TCPSocket client and server.
368461847f8eSopenharmony_ci   * @interface TCPSocketConnection
368561847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
368661847f8eSopenharmony_ci   * @since 10
368761847f8eSopenharmony_ci   */
368861847f8eSopenharmony_ci  export interface TCPSocketConnection {
368961847f8eSopenharmony_ci    /**
369061847f8eSopenharmony_ci     * The id of a client connects to the TCPSocketServer.
369161847f8eSopenharmony_ci     * @type {number}
369261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
369361847f8eSopenharmony_ci     * @since 10
369461847f8eSopenharmony_ci     */
369561847f8eSopenharmony_ci    clientId: number;
369661847f8eSopenharmony_ci
369761847f8eSopenharmony_ci    /**
369861847f8eSopenharmony_ci     * Sends data over a TCPSocketServer connection to client.
369961847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
370061847f8eSopenharmony_ci     * @param { TCPSendOptions } options - Parameters for sending data {@link TCPSendOptions}.
370161847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of send.
370261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
370361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
370461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
370561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
370661847f8eSopenharmony_ci     * @since 10
370761847f8eSopenharmony_ci     */
370861847f8eSopenharmony_ci    send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
370961847f8eSopenharmony_ci
371061847f8eSopenharmony_ci    /**
371161847f8eSopenharmony_ci     * Sends data over a TCPSocketServer connection to client.
371261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
371361847f8eSopenharmony_ci     * @param { TCPSendOptions } options - Parameters for sending data {@link TCPSendOptions}.
371461847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
371561847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
371661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
371761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
371861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
371961847f8eSopenharmony_ci     * @since 10
372061847f8eSopenharmony_ci     */
372161847f8eSopenharmony_ci    send(options: TCPSendOptions): Promise<void>;
372261847f8eSopenharmony_ci
372361847f8eSopenharmony_ci    /**
372461847f8eSopenharmony_ci     * Closes a TCPSocket client connection.
372561847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
372661847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of close.
372761847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
372861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
372961847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
373061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
373161847f8eSopenharmony_ci     * @since 10
373261847f8eSopenharmony_ci     */
373361847f8eSopenharmony_ci    close(callback: AsyncCallback<void>): void;
373461847f8eSopenharmony_ci
373561847f8eSopenharmony_ci    /**
373661847f8eSopenharmony_ci     * Closes a TCPSocket client connection.
373761847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
373861847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
373961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
374061847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
374161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
374261847f8eSopenharmony_ci     * @since 10
374361847f8eSopenharmony_ci     */
374461847f8eSopenharmony_ci    close(): Promise<void>;
374561847f8eSopenharmony_ci
374661847f8eSopenharmony_ci    /**
374761847f8eSopenharmony_ci     * Obtains the peer address of a TCPSocketServer connection.
374861847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
374961847f8eSopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - The callback of getRemoteAddress.
375061847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
375161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
375261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
375361847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
375461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
375561847f8eSopenharmony_ci     * @since 10
375661847f8eSopenharmony_ci     */
375761847f8eSopenharmony_ci    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
375861847f8eSopenharmony_ci
375961847f8eSopenharmony_ci    /**
376061847f8eSopenharmony_ci     * Obtains the peer address of a TCPSocketServer connection.
376161847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
376261847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
376361847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
376461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
376561847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
376661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
376761847f8eSopenharmony_ci     * @since 10
376861847f8eSopenharmony_ci     */
376961847f8eSopenharmony_ci    getRemoteAddress(): Promise<NetAddress>;
377061847f8eSopenharmony_ci
377161847f8eSopenharmony_ci    /**
377261847f8eSopenharmony_ci     * Obtains the local address of a TCPSocketServer connection.
377361847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
377461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
377561847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
377661847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
377761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
377861847f8eSopenharmony_ci     * @since 12
377961847f8eSopenharmony_ci     */
378061847f8eSopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
378161847f8eSopenharmony_ci
378261847f8eSopenharmony_ci    /**
378361847f8eSopenharmony_ci     * Listens for message receiving events of the TCPSocketConnection.
378461847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
378561847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of on.
378661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
378761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
378861847f8eSopenharmony_ci     * @since 10
378961847f8eSopenharmony_ci     */
379061847f8eSopenharmony_ci    /**
379161847f8eSopenharmony_ci     * Listens for message receiving events of the TCPSocketConnection.
379261847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
379361847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
379461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
379561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
379661847f8eSopenharmony_ci     * @since 11
379761847f8eSopenharmony_ci     */
379861847f8eSopenharmony_ci    /**
379961847f8eSopenharmony_ci     * Listens for message receiving events of the TCPSocketConnection.
380061847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
380161847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
380261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
380361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
380461847f8eSopenharmony_ci     * @crossplatform
380561847f8eSopenharmony_ci     * @since 12
380661847f8eSopenharmony_ci     */
380761847f8eSopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
380861847f8eSopenharmony_ci
380961847f8eSopenharmony_ci    /**
381061847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TCPSocketConnection.
381161847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
381261847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of off.
381361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
381461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
381561847f8eSopenharmony_ci     * @since 10
381661847f8eSopenharmony_ci     */
381761847f8eSopenharmony_ci    /**
381861847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TCPSocketConnection.
381961847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
382061847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
382161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
382261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
382361847f8eSopenharmony_ci     * @since 11
382461847f8eSopenharmony_ci     */
382561847f8eSopenharmony_ci    /**
382661847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TCPSocketConnection.
382761847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
382861847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
382961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
383061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
383161847f8eSopenharmony_ci     * @crossplatform
383261847f8eSopenharmony_ci     * @since 12
383361847f8eSopenharmony_ci     */
383461847f8eSopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
383561847f8eSopenharmony_ci
383661847f8eSopenharmony_ci    /**
383761847f8eSopenharmony_ci     * Listens for close events of the TCPSocketConnection.
383861847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
383961847f8eSopenharmony_ci     * @param { Callback<void> } callback - The callback of on.
384061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
384161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
384261847f8eSopenharmony_ci     * @since 10
384361847f8eSopenharmony_ci     */
384461847f8eSopenharmony_ci    on(type: 'close', callback: Callback<void>): void;
384561847f8eSopenharmony_ci
384661847f8eSopenharmony_ci    /**
384761847f8eSopenharmony_ci     * Cancels listening for close events of the TCPSocketConnection.
384861847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
384961847f8eSopenharmony_ci     * @param { Callback<void> } callback - The callback of off.
385061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
385161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
385261847f8eSopenharmony_ci     * @since 10
385361847f8eSopenharmony_ci     */
385461847f8eSopenharmony_ci    off(type: 'close', callback?: Callback<void>): void;
385561847f8eSopenharmony_ci
385661847f8eSopenharmony_ci    /**
385761847f8eSopenharmony_ci     * Listens for error events of the TCPSocketConnection.
385861847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
385961847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
386061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
386161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
386261847f8eSopenharmony_ci     * @since 10
386361847f8eSopenharmony_ci     */
386461847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
386561847f8eSopenharmony_ci
386661847f8eSopenharmony_ci    /**
386761847f8eSopenharmony_ci     * Cancels listening for error events of the TCPSocketConnection.
386861847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
386961847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
387061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
387161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
387261847f8eSopenharmony_ci     * @since 10
387361847f8eSopenharmony_ci     */
387461847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
387561847f8eSopenharmony_ci  }
387661847f8eSopenharmony_ci
387761847f8eSopenharmony_ci  /**
387861847f8eSopenharmony_ci   * Defines a TCPSocket server connection.
387961847f8eSopenharmony_ci   * @interface TCPSocketServer
388061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
388161847f8eSopenharmony_ci   * @since 10
388261847f8eSopenharmony_ci   */
388361847f8eSopenharmony_ci  export interface TCPSocketServer {
388461847f8eSopenharmony_ci    /**
388561847f8eSopenharmony_ci     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
388661847f8eSopenharmony_ci     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
388761847f8eSopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
388861847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
388961847f8eSopenharmony_ci     * @param { NetAddress } address - Network address information {@link NetAddress}.
389061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of listen.
389161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
389261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
389361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
389461847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
389561847f8eSopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
389661847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
389761847f8eSopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
389861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
389961847f8eSopenharmony_ci     * @since 10
390061847f8eSopenharmony_ci     */
390161847f8eSopenharmony_ci    listen(address: NetAddress, callback: AsyncCallback<void>): void;
390261847f8eSopenharmony_ci
390361847f8eSopenharmony_ci    /** 
390461847f8eSopenharmony_ci     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
390561847f8eSopenharmony_ci     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
390661847f8eSopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
390761847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
390861847f8eSopenharmony_ci     * @param { NetAddress } address - Network address information {@link NetAddress}.
390961847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
391061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
391161847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
391261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
391361847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
391461847f8eSopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
391561847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
391661847f8eSopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
391761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
391861847f8eSopenharmony_ci     * @since 10
391961847f8eSopenharmony_ci     */
392061847f8eSopenharmony_ci    listen(address: NetAddress): Promise<void>;
392161847f8eSopenharmony_ci
392261847f8eSopenharmony_ci    /**
392361847f8eSopenharmony_ci     * Obtains the status of the TCPSocketServer connection.
392461847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
392561847f8eSopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - The callback of getState.
392661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
392761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
392861847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
392961847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
393061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
393161847f8eSopenharmony_ci     * @since 10
393261847f8eSopenharmony_ci     */
393361847f8eSopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
393461847f8eSopenharmony_ci
393561847f8eSopenharmony_ci    /**
393661847f8eSopenharmony_ci     * Obtains the status of the TCPSocketServer connection.
393761847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
393861847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
393961847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
394061847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
394161847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
394261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
394361847f8eSopenharmony_ci     * @since 10
394461847f8eSopenharmony_ci     */
394561847f8eSopenharmony_ci    getState(): Promise<SocketStateBase>;
394661847f8eSopenharmony_ci
394761847f8eSopenharmony_ci    /**
394861847f8eSopenharmony_ci     * Sets other attributes of the TCPSocketServer connection.
394961847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
395061847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
395161847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setExtraOptions.
395261847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
395361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
395461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
395561847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
395661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
395761847f8eSopenharmony_ci     * @since 10
395861847f8eSopenharmony_ci     */
395961847f8eSopenharmony_ci    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
396061847f8eSopenharmony_ci
396161847f8eSopenharmony_ci    /**
396261847f8eSopenharmony_ci     * Sets other attributes of the TCPSocketServer connection.
396361847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
396461847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
396561847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
396661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
396761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
396861847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
396961847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
397061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
397161847f8eSopenharmony_ci     * @since 10
397261847f8eSopenharmony_ci     */
397361847f8eSopenharmony_ci    setExtraOptions(options: TCPExtraOptions): Promise<void>;
397461847f8eSopenharmony_ci
397561847f8eSopenharmony_ci    /**
397661847f8eSopenharmony_ci     * Obtains the local address of a TCPSocketServer connection.
397761847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
397861847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
397961847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
398061847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
398161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
398261847f8eSopenharmony_ci     * @since 12
398361847f8eSopenharmony_ci     */
398461847f8eSopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
398561847f8eSopenharmony_ci
398661847f8eSopenharmony_ci    /**
398761847f8eSopenharmony_ci     * Listens for connect events of the TCPSocketServer connection.
398861847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
398961847f8eSopenharmony_ci     * @param { Callback<TCPSocketConnection> } callback - The callback of on.
399061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
399161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
399261847f8eSopenharmony_ci     * @since 10
399361847f8eSopenharmony_ci     */
399461847f8eSopenharmony_ci    on(type: 'connect', callback: Callback<TCPSocketConnection>): void;
399561847f8eSopenharmony_ci
399661847f8eSopenharmony_ci    /**
399761847f8eSopenharmony_ci     * Cancels listening for connect events of the TCPSocketServer connection.
399861847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
399961847f8eSopenharmony_ci     * @param { Callback<TCPSocketConnection> } callback - The callback of off.
400061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
400161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
400261847f8eSopenharmony_ci     * @since 10
400361847f8eSopenharmony_ci     */
400461847f8eSopenharmony_ci    off(type: 'connect', callback?: Callback<TCPSocketConnection>): void;
400561847f8eSopenharmony_ci
400661847f8eSopenharmony_ci    /**
400761847f8eSopenharmony_ci     * Listens for error events of the TCPSocketServer connection.
400861847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
400961847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
401061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
401161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
401261847f8eSopenharmony_ci     * @since 10
401361847f8eSopenharmony_ci     */
401461847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
401561847f8eSopenharmony_ci
401661847f8eSopenharmony_ci    /**
401761847f8eSopenharmony_ci     * Cancels listening for error events of the TCPSocketServer connection.
401861847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
401961847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
402061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
402161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
402261847f8eSopenharmony_ci     * @since 10
402361847f8eSopenharmony_ci     */
402461847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
402561847f8eSopenharmony_ci  }
402661847f8eSopenharmony_ci
402761847f8eSopenharmony_ci  /**
402861847f8eSopenharmony_ci   * Defines the connection of the TLSSocket client and server.
402961847f8eSopenharmony_ci   * @interface TLSSocketConnection
403061847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
403161847f8eSopenharmony_ci   * @since 10
403261847f8eSopenharmony_ci   */
403361847f8eSopenharmony_ci  export interface TLSSocketConnection {
403461847f8eSopenharmony_ci    /**
403561847f8eSopenharmony_ci     * The id of a client connects to the TLSSocketServer.
403661847f8eSopenharmony_ci     * @type {number}
403761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
403861847f8eSopenharmony_ci     * @since 10
403961847f8eSopenharmony_ci     */
404061847f8eSopenharmony_ci    clientId: number;
404161847f8eSopenharmony_ci
404261847f8eSopenharmony_ci    /**
404361847f8eSopenharmony_ci     * Sends data over a TLSSocketServer connection to client.
404461847f8eSopenharmony_ci     * @param { string } data - Parameters for sending data.
404561847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of send.
404661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
404761847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
404861847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
404961847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
405061847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
405161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
405261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
405361847f8eSopenharmony_ci     * @since 10
405461847f8eSopenharmony_ci     */
405561847f8eSopenharmony_ci    /**
405661847f8eSopenharmony_ci     * Sends data over a TLSSocketServer connection to client.
405761847f8eSopenharmony_ci     * @param { string | ArrayBuffer } data - Parameters for sending data.
405861847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of send.
405961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
406061847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
406161847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
406261847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
406361847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
406461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
406561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
406661847f8eSopenharmony_ci     * @since 12
406761847f8eSopenharmony_ci     */
406861847f8eSopenharmony_ci    send(data: string | ArrayBuffer, callback: AsyncCallback<void>): void;
406961847f8eSopenharmony_ci
407061847f8eSopenharmony_ci    /**
407161847f8eSopenharmony_ci     * Sends data over a TLSSocketServer connection to client.
407261847f8eSopenharmony_ci     * @param { string } data - Parameters for sending data.
407361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
407461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
407561847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
407661847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
407761847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
407861847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
407961847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
408061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
408161847f8eSopenharmony_ci     * @since 10
408261847f8eSopenharmony_ci     */
408361847f8eSopenharmony_ci    /**
408461847f8eSopenharmony_ci     * Sends data over a TLSSocketServer connection to client.
408561847f8eSopenharmony_ci     * @param { string | ArrayBuffer } data - Parameters for sending data.
408661847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
408761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
408861847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
408961847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
409061847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
409161847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
409261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
409361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
409461847f8eSopenharmony_ci     * @since 12
409561847f8eSopenharmony_ci     */
409661847f8eSopenharmony_ci    send(data: string | ArrayBuffer): Promise<void>;
409761847f8eSopenharmony_ci
409861847f8eSopenharmony_ci    /**
409961847f8eSopenharmony_ci     * Closes a TLSSocket client connection.
410061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of close.
410161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
410261847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
410361847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
410461847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
410561847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
410661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
410761847f8eSopenharmony_ci     * @since 10
410861847f8eSopenharmony_ci     */
410961847f8eSopenharmony_ci    close(callback: AsyncCallback<void>): void;
411061847f8eSopenharmony_ci
411161847f8eSopenharmony_ci    /**
411261847f8eSopenharmony_ci     * Closes a TLSSocket client connection.
411361847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
411461847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
411561847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
411661847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
411761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
411861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
411961847f8eSopenharmony_ci     * @since 10
412061847f8eSopenharmony_ci     */
412161847f8eSopenharmony_ci    close(): Promise<void>;
412261847f8eSopenharmony_ci
412361847f8eSopenharmony_ci    /**
412461847f8eSopenharmony_ci     * Obtains the peer address of a TLSSocketServer connection.
412561847f8eSopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - The callback of getRemoteAddress.
412661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
412761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
412861847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
412961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
413061847f8eSopenharmony_ci     * @since 10
413161847f8eSopenharmony_ci     */
413261847f8eSopenharmony_ci    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
413361847f8eSopenharmony_ci
413461847f8eSopenharmony_ci    /**
413561847f8eSopenharmony_ci     * Obtains the peer address of a TLSSocketServer connection.
413661847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
413761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
413861847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
413961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
414061847f8eSopenharmony_ci     * @since 10
414161847f8eSopenharmony_ci     */
414261847f8eSopenharmony_ci    getRemoteAddress(): Promise<NetAddress>;
414361847f8eSopenharmony_ci
414461847f8eSopenharmony_ci    /**
414561847f8eSopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
414661847f8eSopenharmony_ci     * an empty object will be returned. If the socket is destroyed, null is returned.</p>
414761847f8eSopenharmony_ci     * It only contains the peer's certificate.
414861847f8eSopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - The callback of getRemoteCertificate.
414961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
415061847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
415161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
415261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
415361847f8eSopenharmony_ci     * @since 10
415461847f8eSopenharmony_ci     */
415561847f8eSopenharmony_ci    getRemoteCertificate(callback: AsyncCallback<X509CertRawData>): void;
415661847f8eSopenharmony_ci
415761847f8eSopenharmony_ci    /**
415861847f8eSopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
415961847f8eSopenharmony_ci     * an empty object will be returned. If the socket is destroyed, null is returned.</p>
416061847f8eSopenharmony_ci     * It only contains the peer's certificate.
416161847f8eSopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
416261847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
416361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
416461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
416561847f8eSopenharmony_ci     * @since 10
416661847f8eSopenharmony_ci     */
416761847f8eSopenharmony_ci    getRemoteCertificate(): Promise<X509CertRawData>;
416861847f8eSopenharmony_ci
416961847f8eSopenharmony_ci    /**
417061847f8eSopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
417161847f8eSopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
417261847f8eSopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - The callback of getCipherSuite.
417361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
417461847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
417561847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
417661847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
417761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
417861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
417961847f8eSopenharmony_ci     * @since 10
418061847f8eSopenharmony_ci     */
418161847f8eSopenharmony_ci    getCipherSuite(callback: AsyncCallback<Array<string>>): void;
418261847f8eSopenharmony_ci
418361847f8eSopenharmony_ci    /**
418461847f8eSopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
418561847f8eSopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
418661847f8eSopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.
418761847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
418861847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
418961847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
419061847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
419161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
419261847f8eSopenharmony_ci     * @since 10
419361847f8eSopenharmony_ci     */
419461847f8eSopenharmony_ci    getCipherSuite(): Promise<Array<string>>;
419561847f8eSopenharmony_ci
419661847f8eSopenharmony_ci    /**
419761847f8eSopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
419861847f8eSopenharmony_ci     * in descending order of priority.</p>
419961847f8eSopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - The callback of getSignatureAlgorithms.
420061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
420161847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
420261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
420361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
420461847f8eSopenharmony_ci     * @since 10
420561847f8eSopenharmony_ci     */
420661847f8eSopenharmony_ci    getSignatureAlgorithms(callback: AsyncCallback<Array<string>>): void;
420761847f8eSopenharmony_ci
420861847f8eSopenharmony_ci    /**
420961847f8eSopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
421061847f8eSopenharmony_ci     * in descending order of priority.</p>
421161847f8eSopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.
421261847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
421361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
421461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
421561847f8eSopenharmony_ci     * @since 10
421661847f8eSopenharmony_ci     */
421761847f8eSopenharmony_ci    getSignatureAlgorithms(): Promise<Array<string>>;
421861847f8eSopenharmony_ci
421961847f8eSopenharmony_ci    /**
422061847f8eSopenharmony_ci     * Obtains the local address of a TLSSocketServer connection.
422161847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
422261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
422361847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
422461847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
422561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
422661847f8eSopenharmony_ci     * @since 12
422761847f8eSopenharmony_ci     */
422861847f8eSopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
422961847f8eSopenharmony_ci
423061847f8eSopenharmony_ci    /**
423161847f8eSopenharmony_ci     * Listens for message receiving events of the TLSSocketConnection.
423261847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
423361847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of on.
423461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
423561847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
423661847f8eSopenharmony_ci     * @since 10
423761847f8eSopenharmony_ci     */
423861847f8eSopenharmony_ci    /**
423961847f8eSopenharmony_ci     * Listens for message receiving events of the TLSSocketConnection.
424061847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
424161847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
424261847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
424361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
424461847f8eSopenharmony_ci     * @since 11
424561847f8eSopenharmony_ci     */
424661847f8eSopenharmony_ci    /**
424761847f8eSopenharmony_ci     * Listens for message receiving events of the TLSSocketConnection.
424861847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
424961847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
425061847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
425161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
425261847f8eSopenharmony_ci     * @crossplatform
425361847f8eSopenharmony_ci     * @since 12
425461847f8eSopenharmony_ci     */
425561847f8eSopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
425661847f8eSopenharmony_ci
425761847f8eSopenharmony_ci    /**
425861847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TLSSocketConnection.
425961847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
426061847f8eSopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of off.
426161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
426261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
426361847f8eSopenharmony_ci     * @since 10
426461847f8eSopenharmony_ci     */
426561847f8eSopenharmony_ci    /**
426661847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TLSSocketConnection.
426761847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
426861847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
426961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
427061847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
427161847f8eSopenharmony_ci     * @since 11
427261847f8eSopenharmony_ci     */
427361847f8eSopenharmony_ci    /**
427461847f8eSopenharmony_ci     * Cancels listening for message receiving events of the TLSSocketConnection.
427561847f8eSopenharmony_ci     * @param { 'message' } type - Indicates Event name.
427661847f8eSopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
427761847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
427861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
427961847f8eSopenharmony_ci     * @crossplatform
428061847f8eSopenharmony_ci     * @since 12
428161847f8eSopenharmony_ci     */
428261847f8eSopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
428361847f8eSopenharmony_ci
428461847f8eSopenharmony_ci    /**
428561847f8eSopenharmony_ci     * Listens for close events of the TLSSocketConnection.
428661847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
428761847f8eSopenharmony_ci     * @param { Callback<void> } callback - The callback of on.
428861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
428961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
429061847f8eSopenharmony_ci     * @since 10
429161847f8eSopenharmony_ci     */
429261847f8eSopenharmony_ci    on(type: 'close', callback: Callback<void>): void;
429361847f8eSopenharmony_ci
429461847f8eSopenharmony_ci    /**
429561847f8eSopenharmony_ci     * Cancels listening for close events of the TLSSocketConnection.
429661847f8eSopenharmony_ci     * @param { 'close' } type - Indicates Event name.
429761847f8eSopenharmony_ci     * @param { Callback<void> } callback - The callback of off.
429861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
429961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
430061847f8eSopenharmony_ci     * @since 10
430161847f8eSopenharmony_ci     */
430261847f8eSopenharmony_ci    off(type: 'close', callback?: Callback<void>): void;
430361847f8eSopenharmony_ci
430461847f8eSopenharmony_ci    /**
430561847f8eSopenharmony_ci     * Listens for error events of the TLSSocketConnection.
430661847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
430761847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
430861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
430961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
431061847f8eSopenharmony_ci     * @since 10
431161847f8eSopenharmony_ci     */
431261847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
431361847f8eSopenharmony_ci
431461847f8eSopenharmony_ci    /**
431561847f8eSopenharmony_ci     * Cancels listening for error events of the TLSSocketConnection.
431661847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
431761847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
431861847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
431961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
432061847f8eSopenharmony_ci     * @since 10
432161847f8eSopenharmony_ci     */
432261847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
432361847f8eSopenharmony_ci  }
432461847f8eSopenharmony_ci
432561847f8eSopenharmony_ci  /**
432661847f8eSopenharmony_ci   * Defines the socket connection information.
432761847f8eSopenharmony_ci   * @interface SocketMessageInfo
432861847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
432961847f8eSopenharmony_ci   * @crossplatform
433061847f8eSopenharmony_ci   * @since 11
433161847f8eSopenharmony_ci   */
433261847f8eSopenharmony_ci  export interface SocketMessageInfo {
433361847f8eSopenharmony_ci    /**
433461847f8eSopenharmony_ci     * Receive the message event.
433561847f8eSopenharmony_ci     * @type { ArrayBuffer }
433661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
433761847f8eSopenharmony_ci     * @crossplatform
433861847f8eSopenharmony_ci     * @since 11
433961847f8eSopenharmony_ci     */
434061847f8eSopenharmony_ci    message: ArrayBuffer;
434161847f8eSopenharmony_ci    /**
434261847f8eSopenharmony_ci     * Socket connection information.
434361847f8eSopenharmony_ci     * @type { SocketRemoteInfo }
434461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
434561847f8eSopenharmony_ci     * @crossplatform
434661847f8eSopenharmony_ci     * @since 11
434761847f8eSopenharmony_ci     */
434861847f8eSopenharmony_ci    remoteInfo: SocketRemoteInfo;
434961847f8eSopenharmony_ci  }
435061847f8eSopenharmony_ci
435161847f8eSopenharmony_ci  /**
435261847f8eSopenharmony_ci   * Defines a TLSSocketServer server connection.
435361847f8eSopenharmony_ci   * @interface TLSSocketServer
435461847f8eSopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
435561847f8eSopenharmony_ci   * @since 10
435661847f8eSopenharmony_ci   */
435761847f8eSopenharmony_ci  export interface TLSSocketServer {
435861847f8eSopenharmony_ci    /**
435961847f8eSopenharmony_ci     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
436061847f8eSopenharmony_ci     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
436161847f8eSopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
436261847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
436361847f8eSopenharmony_ci     * @param { TLSConnectOptions } options - TLS connection options {@link TLSConnectOptions}.
436461847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of listen.
436561847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
436661847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
436761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
436861847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
436961847f8eSopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
437061847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
437161847f8eSopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
437261847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
437361847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
437461847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
437561847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
437661847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
437761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
437861847f8eSopenharmony_ci     * @since 10
437961847f8eSopenharmony_ci     */
438061847f8eSopenharmony_ci    listen(options: TLSConnectOptions, callback: AsyncCallback<void>): void;
438161847f8eSopenharmony_ci
438261847f8eSopenharmony_ci    /** 
438361847f8eSopenharmony_ci     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
438461847f8eSopenharmony_ci     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
438561847f8eSopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
438661847f8eSopenharmony_ci     * @permission ohos.permission.INTERNET
438761847f8eSopenharmony_ci     * @param { TLSConnectOptions } options - TLS connection options {@link TLSConnectOptions}.
438861847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
438961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
439061847f8eSopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
439161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
439261847f8eSopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
439361847f8eSopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
439461847f8eSopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
439561847f8eSopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
439661847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
439761847f8eSopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
439861847f8eSopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
439961847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
440061847f8eSopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
440161847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
440261847f8eSopenharmony_ci     * @since 10
440361847f8eSopenharmony_ci     */
440461847f8eSopenharmony_ci    listen(options: TLSConnectOptions): Promise<void>;
440561847f8eSopenharmony_ci
440661847f8eSopenharmony_ci    /**
440761847f8eSopenharmony_ci     * Obtains the status of the TLSSocketServer connection.
440861847f8eSopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - The callback of getState.
440961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
441061847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
441161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
441261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
441361847f8eSopenharmony_ci     * @since 10
441461847f8eSopenharmony_ci     */
441561847f8eSopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
441661847f8eSopenharmony_ci
441761847f8eSopenharmony_ci    /**
441861847f8eSopenharmony_ci     * Obtains the status of the TLSSocketServer connection.
441961847f8eSopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
442061847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
442161847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
442261847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
442361847f8eSopenharmony_ci     * @since 10
442461847f8eSopenharmony_ci     */
442561847f8eSopenharmony_ci    getState(): Promise<SocketStateBase>;
442661847f8eSopenharmony_ci
442761847f8eSopenharmony_ci    /**
442861847f8eSopenharmony_ci     * Sets other attributes of the TLSSocketServer connection.
442961847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
443061847f8eSopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setExtraOptions.
443161847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
443261847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
443361847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
443461847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
443561847f8eSopenharmony_ci     * @since 10
443661847f8eSopenharmony_ci     */
443761847f8eSopenharmony_ci    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
443861847f8eSopenharmony_ci
443961847f8eSopenharmony_ci    /**
444061847f8eSopenharmony_ci     * Sets other attributes of the TLSSocketServer connection.
444161847f8eSopenharmony_ci     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
444261847f8eSopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
444361847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
444461847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
444561847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
444661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
444761847f8eSopenharmony_ci     * @since 10
444861847f8eSopenharmony_ci     */
444961847f8eSopenharmony_ci    setExtraOptions(options: TCPExtraOptions): Promise<void>;
445061847f8eSopenharmony_ci
445161847f8eSopenharmony_ci    /**
445261847f8eSopenharmony_ci     * Returns an object representing a local certificate.
445361847f8eSopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - The callback of getCertificate.
445461847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
445561847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
445661847f8eSopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
445761847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
445861847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
445961847f8eSopenharmony_ci     * @since 10
446061847f8eSopenharmony_ci     */
446161847f8eSopenharmony_ci    getCertificate(callback: AsyncCallback<X509CertRawData>): void;
446261847f8eSopenharmony_ci
446361847f8eSopenharmony_ci    /**
446461847f8eSopenharmony_ci     * Returns an object representing a local certificate.
446561847f8eSopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
446661847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
446761847f8eSopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
446861847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
446961847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
447061847f8eSopenharmony_ci     * @since 10
447161847f8eSopenharmony_ci     */
447261847f8eSopenharmony_ci    getCertificate(): Promise<X509CertRawData>;
447361847f8eSopenharmony_ci
447461847f8eSopenharmony_ci    /**
447561847f8eSopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
447661847f8eSopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
447761847f8eSopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
447861847f8eSopenharmony_ci     * @param { AsyncCallback<string> } callback - The callback of getProtocol.
447961847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
448061847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
448161847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
448261847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
448361847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
448461847f8eSopenharmony_ci     * @since 10
448561847f8eSopenharmony_ci     */
448661847f8eSopenharmony_ci    getProtocol(callback: AsyncCallback<string>): void;
448761847f8eSopenharmony_ci
448861847f8eSopenharmony_ci    /**
448961847f8eSopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
449061847f8eSopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
449161847f8eSopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
449261847f8eSopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
449361847f8eSopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
449461847f8eSopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
449561847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
449661847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
449761847f8eSopenharmony_ci     * @since 10
449861847f8eSopenharmony_ci     */
449961847f8eSopenharmony_ci    getProtocol(): Promise<string>;
450061847f8eSopenharmony_ci
450161847f8eSopenharmony_ci    /**
450261847f8eSopenharmony_ci     * Obtains the local address of the TLSSocketServer connection.
450361847f8eSopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
450461847f8eSopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
450561847f8eSopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
450661847f8eSopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
450761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
450861847f8eSopenharmony_ci     * @since 12
450961847f8eSopenharmony_ci     */
451061847f8eSopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
451161847f8eSopenharmony_ci
451261847f8eSopenharmony_ci    /**
451361847f8eSopenharmony_ci     * Listens for connect events of the TLSSocketServer connection.
451461847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
451561847f8eSopenharmony_ci     * @param { Callback<TLSSocketConnection> } callback - The callback of on.
451661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
451761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
451861847f8eSopenharmony_ci     * @since 10
451961847f8eSopenharmony_ci     */
452061847f8eSopenharmony_ci    on(type: 'connect', callback: Callback<TLSSocketConnection>): void;
452161847f8eSopenharmony_ci
452261847f8eSopenharmony_ci    /**
452361847f8eSopenharmony_ci     * Cancels listening for connect events of the TLSSocketServer connection.
452461847f8eSopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
452561847f8eSopenharmony_ci     * @param { Callback<TLSSocketConnection> } callback - The callback of off.
452661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
452761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
452861847f8eSopenharmony_ci     * @since 10
452961847f8eSopenharmony_ci     */
453061847f8eSopenharmony_ci    off(type: 'connect', callback?: Callback<TLSSocketConnection>): void;
453161847f8eSopenharmony_ci
453261847f8eSopenharmony_ci    /**
453361847f8eSopenharmony_ci     * Listens for error events of the TLSSocketServer connection.
453461847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
453561847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
453661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
453761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
453861847f8eSopenharmony_ci     * @since 10
453961847f8eSopenharmony_ci     */
454061847f8eSopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
454161847f8eSopenharmony_ci
454261847f8eSopenharmony_ci    /**
454361847f8eSopenharmony_ci     * Cancels listening for error events of the TLSSocketServer connection.
454461847f8eSopenharmony_ci     * @param { 'error' } type - Indicates Event name.
454561847f8eSopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
454661847f8eSopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
454761847f8eSopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
454861847f8eSopenharmony_ci     * @since 10
454961847f8eSopenharmony_ci     */
455061847f8eSopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
455161847f8eSopenharmony_ci  }
455261847f8eSopenharmony_ci}
455361847f8eSopenharmony_ci
455461847f8eSopenharmony_ciexport default socket;
4555