11e934351Sopenharmony_ci/*
21e934351Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
31e934351Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41e934351Sopenharmony_ci * you may not use this file except in compliance with the License.
51e934351Sopenharmony_ci * You may obtain a copy of the License at
61e934351Sopenharmony_ci *
71e934351Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81e934351Sopenharmony_ci *
91e934351Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101e934351Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111e934351Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121e934351Sopenharmony_ci * See the License for the specific language governing permissions and
131e934351Sopenharmony_ci * limitations under the License.
141e934351Sopenharmony_ci */
151e934351Sopenharmony_ci
161e934351Sopenharmony_ci/**
171e934351Sopenharmony_ci * @file
181e934351Sopenharmony_ci * @kit NetworkKit
191e934351Sopenharmony_ci */
201e934351Sopenharmony_ci
211e934351Sopenharmony_ciimport type { AsyncCallback, Callback, ErrorCallback } from './@ohos.base';
221e934351Sopenharmony_ciimport connection from "./@ohos.net.connection";
231e934351Sopenharmony_ciimport type cert from './@ohos.security.cert';
241e934351Sopenharmony_ci
251e934351Sopenharmony_ci/**
261e934351Sopenharmony_ci * Provides TCP and UDP Socket APIs.
271e934351Sopenharmony_ci * @namespace socket
281e934351Sopenharmony_ci * @syscap SystemCapability.Communication.NetStack
291e934351Sopenharmony_ci * @since 7
301e934351Sopenharmony_ci */
311e934351Sopenharmony_ci/**
321e934351Sopenharmony_ci * Provides TCP and UDP Socket APIs.
331e934351Sopenharmony_ci * @namespace socket
341e934351Sopenharmony_ci * @syscap SystemCapability.Communication.NetStack
351e934351Sopenharmony_ci * @crossplatform
361e934351Sopenharmony_ci * @since 10
371e934351Sopenharmony_ci */
381e934351Sopenharmony_cideclare namespace socket {
391e934351Sopenharmony_ci  export import NetAddress = connection.NetAddress;
401e934351Sopenharmony_ci  /**
411e934351Sopenharmony_ci   * Deposit certificate
421e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
431e934351Sopenharmony_ci   * @since 9
441e934351Sopenharmony_ci   */
451e934351Sopenharmony_ci  /**
461e934351Sopenharmony_ci   * Deposit certificate
471e934351Sopenharmony_ci   * @typedef { cert.EncodingBlob }
481e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
491e934351Sopenharmony_ci   * @crossplatform
501e934351Sopenharmony_ci   * @since 10
511e934351Sopenharmony_ci   */
521e934351Sopenharmony_ci  export type X509CertRawData = cert.EncodingBlob;
531e934351Sopenharmony_ci
541e934351Sopenharmony_ci  /**
551e934351Sopenharmony_ci   * Creates a UDPSocket object.
561e934351Sopenharmony_ci   * @returns { UDPSocket } the UDPSocket of the constructUDPSocketInstance.
571e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
581e934351Sopenharmony_ci   * @since 7
591e934351Sopenharmony_ci   */
601e934351Sopenharmony_ci  /**
611e934351Sopenharmony_ci   * Creates a UDPSocket object.
621e934351Sopenharmony_ci   * @returns { UDPSocket } the UDPSocket of the constructUDPSocketInstance.
631e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
641e934351Sopenharmony_ci   * @crossplatform
651e934351Sopenharmony_ci   * @since 10
661e934351Sopenharmony_ci   */
671e934351Sopenharmony_ci  function constructUDPSocketInstance(): UDPSocket;
681e934351Sopenharmony_ci
691e934351Sopenharmony_ci  /**
701e934351Sopenharmony_ci   * Creates a MulticastSocket object.
711e934351Sopenharmony_ci   * @returns { MulticastSocket } the MulticastSocket of the constructMulticastSocketInstance.
721e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
731e934351Sopenharmony_ci   * @since 11
741e934351Sopenharmony_ci   */
751e934351Sopenharmony_ci  /**
761e934351Sopenharmony_ci   * Creates a MulticastSocket object.
771e934351Sopenharmony_ci   * @returns { MulticastSocket } the MulticastSocket of the constructMulticastSocketInstance.
781e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
791e934351Sopenharmony_ci   * @crossplatform
801e934351Sopenharmony_ci   * @since 12
811e934351Sopenharmony_ci   */
821e934351Sopenharmony_ci  function constructMulticastSocketInstance(): MulticastSocket;
831e934351Sopenharmony_ci
841e934351Sopenharmony_ci  /**
851e934351Sopenharmony_ci   * Creates a TCPSocket object.
861e934351Sopenharmony_ci   * @returns { TCPSocket } the TCPSocket of the constructTCPSocketInstance.
871e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
881e934351Sopenharmony_ci   * @since 7
891e934351Sopenharmony_ci   */
901e934351Sopenharmony_ci  /**
911e934351Sopenharmony_ci   * Creates a TCPSocket object.
921e934351Sopenharmony_ci   * @returns { TCPSocket } the TCPSocket of the constructTCPSocketInstance.
931e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
941e934351Sopenharmony_ci   * @crossplatform
951e934351Sopenharmony_ci   * @since 10
961e934351Sopenharmony_ci   */
971e934351Sopenharmony_ci  function constructTCPSocketInstance(): TCPSocket;
981e934351Sopenharmony_ci
991e934351Sopenharmony_ci  /**
1001e934351Sopenharmony_ci   * Creates a TLSSocket object.
1011e934351Sopenharmony_ci   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
1021e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1031e934351Sopenharmony_ci   * @since 9
1041e934351Sopenharmony_ci   */
1051e934351Sopenharmony_ci  /**
1061e934351Sopenharmony_ci   * Creates a TLSSocket object.
1071e934351Sopenharmony_ci   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
1081e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1091e934351Sopenharmony_ci   * @crossplatform
1101e934351Sopenharmony_ci   * @since 10
1111e934351Sopenharmony_ci   */
1121e934351Sopenharmony_ci  function constructTLSSocketInstance(): TLSSocket;
1131e934351Sopenharmony_ci
1141e934351Sopenharmony_ci  /**
1151e934351Sopenharmony_ci   * Creates a TLSSocket object with a TCPSocket object.
1161e934351Sopenharmony_ci   * @param { TCPSocket } tcpSocket - Parameter for creating a TLSSocket object.
1171e934351Sopenharmony_ci   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
1181e934351Sopenharmony_ci   * @throws { BusinessError } 401 - Parameter error.
1191e934351Sopenharmony_ci   * @throws { BusinessError } 2300002 - System internal error.
1201e934351Sopenharmony_ci   * @throws { BusinessError } 2303601 - Invalid socket FD.
1211e934351Sopenharmony_ci   * @throws { BusinessError } 2303602 - Socket is not connected.
1221e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1231e934351Sopenharmony_ci   * @since 12
1241e934351Sopenharmony_ci   */
1251e934351Sopenharmony_ci  function constructTLSSocketInstance(tcpSocket: TCPSocket): TLSSocket;
1261e934351Sopenharmony_ci
1271e934351Sopenharmony_ci  /**
1281e934351Sopenharmony_ci   * Creates a TCPSocketServer object.
1291e934351Sopenharmony_ci   * @returns { TCPSocketServer } the TCPSocketServer of the constructTCPSocketServerInstance.
1301e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1311e934351Sopenharmony_ci   * @since 10
1321e934351Sopenharmony_ci   */
1331e934351Sopenharmony_ci  function constructTCPSocketServerInstance(): TCPSocketServer;
1341e934351Sopenharmony_ci
1351e934351Sopenharmony_ci  /**
1361e934351Sopenharmony_ci   * Creates a TLSSocketServer object.
1371e934351Sopenharmony_ci   * @returns { TLSSocketServer } the TLSSocketServer of the constructTLSSocketServerInstance.
1381e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1391e934351Sopenharmony_ci   * @since 10
1401e934351Sopenharmony_ci   */
1411e934351Sopenharmony_ci  function constructTLSSocketServerInstance(): TLSSocketServer;
1421e934351Sopenharmony_ci
1431e934351Sopenharmony_ci  /**
1441e934351Sopenharmony_ci   * Creates a LocalSocket object.
1451e934351Sopenharmony_ci   * @returns { LocalSocket } the LocalSocket of the constructLocalSocketInstance.
1461e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1471e934351Sopenharmony_ci   * @since 11
1481e934351Sopenharmony_ci   */
1491e934351Sopenharmony_ci  /**
1501e934351Sopenharmony_ci   * Creates a LocalSocket object.
1511e934351Sopenharmony_ci   * @returns { LocalSocket } the LocalSocket of the constructLocalSocketInstance.
1521e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1531e934351Sopenharmony_ci   * @crossplatform
1541e934351Sopenharmony_ci   * @since 12
1551e934351Sopenharmony_ci   */
1561e934351Sopenharmony_ci  function constructLocalSocketInstance(): LocalSocket;
1571e934351Sopenharmony_ci
1581e934351Sopenharmony_ci  /**
1591e934351Sopenharmony_ci   * Creates a LocalSocketServer object.
1601e934351Sopenharmony_ci   * @returns { LocalSocketServer } the LocalSocketServer of the constructLocalSocketServerInstance.
1611e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1621e934351Sopenharmony_ci   * @since 11
1631e934351Sopenharmony_ci   */
1641e934351Sopenharmony_ci  /**
1651e934351Sopenharmony_ci   * Creates a LocalSocketServer object.
1661e934351Sopenharmony_ci   * @returns { LocalSocketServer } the LocalSocketServer of the constructLocalSocketServerInstance.
1671e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1681e934351Sopenharmony_ci   * @crossplatform
1691e934351Sopenharmony_ci   * @since 12
1701e934351Sopenharmony_ci   */
1711e934351Sopenharmony_ci  function constructLocalSocketServerInstance(): LocalSocketServer;
1721e934351Sopenharmony_ci
1731e934351Sopenharmony_ci  /**
1741e934351Sopenharmony_ci   * Defines the parameters for sending data over the UDPSocket connection.
1751e934351Sopenharmony_ci   * @interface UDPSendOptions
1761e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1771e934351Sopenharmony_ci   * @since 7
1781e934351Sopenharmony_ci   */
1791e934351Sopenharmony_ci  /**
1801e934351Sopenharmony_ci   * Defines the parameters for sending data over the UDPSocket connection.
1811e934351Sopenharmony_ci   * @interface UDPSendOptions
1821e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
1831e934351Sopenharmony_ci   * @crossplatform
1841e934351Sopenharmony_ci   * @since 10
1851e934351Sopenharmony_ci   */
1861e934351Sopenharmony_ci  export interface UDPSendOptions {
1871e934351Sopenharmony_ci    /**
1881e934351Sopenharmony_ci     * Data to send.
1891e934351Sopenharmony_ci     * @type {string | ArrayBuffer}
1901e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1911e934351Sopenharmony_ci     * @since 7
1921e934351Sopenharmony_ci     */
1931e934351Sopenharmony_ci    /**
1941e934351Sopenharmony_ci     * Data to send.
1951e934351Sopenharmony_ci     * @type {string | ArrayBuffer}
1961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
1971e934351Sopenharmony_ci     * @crossplatform
1981e934351Sopenharmony_ci     * @since 10
1991e934351Sopenharmony_ci     */
2001e934351Sopenharmony_ci    data: string | ArrayBuffer;
2011e934351Sopenharmony_ci
2021e934351Sopenharmony_ci    /**
2031e934351Sopenharmony_ci     * Destination address.
2041e934351Sopenharmony_ci     * @type {NetAddress}
2051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2061e934351Sopenharmony_ci     * @since 7
2071e934351Sopenharmony_ci     */
2081e934351Sopenharmony_ci    /**
2091e934351Sopenharmony_ci     * Destination address.
2101e934351Sopenharmony_ci     * @type {NetAddress}
2111e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2121e934351Sopenharmony_ci     * @crossplatform
2131e934351Sopenharmony_ci     * @since 10
2141e934351Sopenharmony_ci     */
2151e934351Sopenharmony_ci    address: NetAddress;
2161e934351Sopenharmony_ci  }
2171e934351Sopenharmony_ci
2181e934351Sopenharmony_ci  /**
2191e934351Sopenharmony_ci   * @interface ExtraOptionsBase
2201e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
2211e934351Sopenharmony_ci   * @since 7
2221e934351Sopenharmony_ci   */
2231e934351Sopenharmony_ci  /**
2241e934351Sopenharmony_ci   * @interface ExtraOptionsBase
2251e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
2261e934351Sopenharmony_ci   * @crossplatform
2271e934351Sopenharmony_ci   * @since 10
2281e934351Sopenharmony_ci   */
2291e934351Sopenharmony_ci  export interface ExtraOptionsBase {
2301e934351Sopenharmony_ci    /**
2311e934351Sopenharmony_ci     * Size of the receive buffer, in MBS.
2321e934351Sopenharmony_ci     * @type {?number}
2331e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2341e934351Sopenharmony_ci     * @since 7
2351e934351Sopenharmony_ci     */
2361e934351Sopenharmony_ci    /**
2371e934351Sopenharmony_ci     * Size of the receive buffer, in MBS.
2381e934351Sopenharmony_ci     * @type {?number}
2391e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2401e934351Sopenharmony_ci     * @crossplatform
2411e934351Sopenharmony_ci     * @since 10
2421e934351Sopenharmony_ci     */
2431e934351Sopenharmony_ci    receiveBufferSize?: number;
2441e934351Sopenharmony_ci
2451e934351Sopenharmony_ci    /**
2461e934351Sopenharmony_ci     * Size of the send buffer, in MBS.
2471e934351Sopenharmony_ci     * @type {?number}
2481e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2491e934351Sopenharmony_ci     * @since 7
2501e934351Sopenharmony_ci     */
2511e934351Sopenharmony_ci    /**
2521e934351Sopenharmony_ci     * Size of the send buffer, in MBS.
2531e934351Sopenharmony_ci     * @type {?number}
2541e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2551e934351Sopenharmony_ci     * @crossplatform
2561e934351Sopenharmony_ci     * @since 10
2571e934351Sopenharmony_ci     */
2581e934351Sopenharmony_ci    sendBufferSize?: number;
2591e934351Sopenharmony_ci
2601e934351Sopenharmony_ci    /**
2611e934351Sopenharmony_ci     * Whether to reuse addresses. The default value is false.
2621e934351Sopenharmony_ci     * @type {?boolean}
2631e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2641e934351Sopenharmony_ci     * @since 7
2651e934351Sopenharmony_ci     */
2661e934351Sopenharmony_ci    /**
2671e934351Sopenharmony_ci     * Whether to reuse addresses. The default value is false.
2681e934351Sopenharmony_ci     * @type {?boolean}
2691e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2701e934351Sopenharmony_ci     * @crossplatform
2711e934351Sopenharmony_ci     * @since 10
2721e934351Sopenharmony_ci     */
2731e934351Sopenharmony_ci    reuseAddress?: boolean;
2741e934351Sopenharmony_ci
2751e934351Sopenharmony_ci    /**
2761e934351Sopenharmony_ci     * Timeout duration of the UDPSocket connection, in milliseconds.
2771e934351Sopenharmony_ci     * @type {?number}
2781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2791e934351Sopenharmony_ci     * @since 7
2801e934351Sopenharmony_ci     */
2811e934351Sopenharmony_ci    /**
2821e934351Sopenharmony_ci     * Timeout duration of the UDPSocket connection, in milliseconds.
2831e934351Sopenharmony_ci     * @type {?number}
2841e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
2851e934351Sopenharmony_ci     * @crossplatform
2861e934351Sopenharmony_ci     * @since 10
2871e934351Sopenharmony_ci     */
2881e934351Sopenharmony_ci    socketTimeout?: number;
2891e934351Sopenharmony_ci  }
2901e934351Sopenharmony_ci
2911e934351Sopenharmony_ci  /**
2921e934351Sopenharmony_ci   * Defines other properties of the UDPSocket connection.
2931e934351Sopenharmony_ci   * @interface UDPExtraOptions
2941e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
2951e934351Sopenharmony_ci   * @since 7
2961e934351Sopenharmony_ci   */
2971e934351Sopenharmony_ci  /**
2981e934351Sopenharmony_ci   * Defines other properties of the UDPSocket connection.
2991e934351Sopenharmony_ci   * @interface UDPExtraOptions
3001e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3011e934351Sopenharmony_ci   * @crossplatform
3021e934351Sopenharmony_ci   * @since 10
3031e934351Sopenharmony_ci   */
3041e934351Sopenharmony_ci  export interface UDPExtraOptions extends ExtraOptionsBase {
3051e934351Sopenharmony_ci    /**
3061e934351Sopenharmony_ci     * Whether to send broadcast messages. The default value is false.
3071e934351Sopenharmony_ci     * @type {?boolean}
3081e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3091e934351Sopenharmony_ci     * @since 7
3101e934351Sopenharmony_ci     */
3111e934351Sopenharmony_ci    /**
3121e934351Sopenharmony_ci     * Whether to send broadcast messages. The default value is false.
3131e934351Sopenharmony_ci     * @type {?boolean}
3141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3151e934351Sopenharmony_ci     * @crossplatform
3161e934351Sopenharmony_ci     * @since 10
3171e934351Sopenharmony_ci     */
3181e934351Sopenharmony_ci    broadcast?: boolean;
3191e934351Sopenharmony_ci  }
3201e934351Sopenharmony_ci
3211e934351Sopenharmony_ci  /**
3221e934351Sopenharmony_ci   * Defines the status of the socket connection.
3231e934351Sopenharmony_ci   * @interface SocketStateBase
3241e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3251e934351Sopenharmony_ci   * @since 7
3261e934351Sopenharmony_ci   */
3271e934351Sopenharmony_ci  /**
3281e934351Sopenharmony_ci   * Defines the status of the socket connection.
3291e934351Sopenharmony_ci   * @interface SocketStateBase
3301e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3311e934351Sopenharmony_ci   * @crossplatform
3321e934351Sopenharmony_ci   * @since 10
3331e934351Sopenharmony_ci   */
3341e934351Sopenharmony_ci  export interface SocketStateBase {
3351e934351Sopenharmony_ci    /**
3361e934351Sopenharmony_ci     * Whether the connection is in the bound state.
3371e934351Sopenharmony_ci     * @type {boolean}
3381e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3391e934351Sopenharmony_ci     * @since 7
3401e934351Sopenharmony_ci     */
3411e934351Sopenharmony_ci    /**
3421e934351Sopenharmony_ci     * Whether the connection is in the bound state.
3431e934351Sopenharmony_ci     * @type {boolean}
3441e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3451e934351Sopenharmony_ci     * @crossplatform
3461e934351Sopenharmony_ci     * @since 10
3471e934351Sopenharmony_ci     */
3481e934351Sopenharmony_ci    isBound: boolean;
3491e934351Sopenharmony_ci
3501e934351Sopenharmony_ci    /**
3511e934351Sopenharmony_ci     * Whether the connection is in the closed state.
3521e934351Sopenharmony_ci     * @type {boolean}
3531e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3541e934351Sopenharmony_ci     * @since 7
3551e934351Sopenharmony_ci     */
3561e934351Sopenharmony_ci    /**
3571e934351Sopenharmony_ci     * Whether the connection is in the closed state.
3581e934351Sopenharmony_ci     * @type {boolean}
3591e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3601e934351Sopenharmony_ci     * @crossplatform
3611e934351Sopenharmony_ci     * @since 10
3621e934351Sopenharmony_ci     */
3631e934351Sopenharmony_ci    isClose: boolean;
3641e934351Sopenharmony_ci
3651e934351Sopenharmony_ci    /**
3661e934351Sopenharmony_ci     * Whether the connection is in the connected state.
3671e934351Sopenharmony_ci     * @type {boolean}
3681e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3691e934351Sopenharmony_ci     * @since 7
3701e934351Sopenharmony_ci     */
3711e934351Sopenharmony_ci    /**
3721e934351Sopenharmony_ci     * Whether the connection is in the connected state.
3731e934351Sopenharmony_ci     * @type {boolean}
3741e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3751e934351Sopenharmony_ci     * @crossplatform
3761e934351Sopenharmony_ci     * @since 10
3771e934351Sopenharmony_ci     */
3781e934351Sopenharmony_ci    isConnected: boolean;
3791e934351Sopenharmony_ci  }
3801e934351Sopenharmony_ci
3811e934351Sopenharmony_ci  /**
3821e934351Sopenharmony_ci   * Defines information about the socket connection.
3831e934351Sopenharmony_ci   * @interface SocketRemoteInfo
3841e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3851e934351Sopenharmony_ci   * @since 7
3861e934351Sopenharmony_ci   */
3871e934351Sopenharmony_ci  /**
3881e934351Sopenharmony_ci   * Defines information about the socket connection.
3891e934351Sopenharmony_ci   * @interface SocketRemoteInfo
3901e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
3911e934351Sopenharmony_ci   * @crossplatform
3921e934351Sopenharmony_ci   * @since 10
3931e934351Sopenharmony_ci   */
3941e934351Sopenharmony_ci  export interface SocketRemoteInfo {
3951e934351Sopenharmony_ci    /**
3961e934351Sopenharmony_ci     * Bound IP address.
3971e934351Sopenharmony_ci     * @type {string}
3981e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
3991e934351Sopenharmony_ci     * @since 7
4001e934351Sopenharmony_ci     */
4011e934351Sopenharmony_ci    /**
4021e934351Sopenharmony_ci     * Bound IP address.
4031e934351Sopenharmony_ci     * @type {string}
4041e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4051e934351Sopenharmony_ci     * @crossplatform
4061e934351Sopenharmony_ci     * @since 10
4071e934351Sopenharmony_ci     */
4081e934351Sopenharmony_ci    address: string;
4091e934351Sopenharmony_ci
4101e934351Sopenharmony_ci    /**
4111e934351Sopenharmony_ci     * Network protocol type. The options are as follows: IPv4, IPv6.
4121e934351Sopenharmony_ci     * @type {'IPv4' | 'IPv6'}
4131e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4141e934351Sopenharmony_ci     * @since 7
4151e934351Sopenharmony_ci     */
4161e934351Sopenharmony_ci    /**
4171e934351Sopenharmony_ci     * Network protocol type. The options are as follows: IPv4, IPv6.
4181e934351Sopenharmony_ci     * @type {'IPv4' | 'IPv6'}
4191e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4201e934351Sopenharmony_ci     * @crossplatform
4211e934351Sopenharmony_ci     * @since 10
4221e934351Sopenharmony_ci     */
4231e934351Sopenharmony_ci    family: 'IPv4' | 'IPv6';
4241e934351Sopenharmony_ci
4251e934351Sopenharmony_ci    /**
4261e934351Sopenharmony_ci     * Port number. The value ranges from 0 to 65535.
4271e934351Sopenharmony_ci     * @type {number}
4281e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4291e934351Sopenharmony_ci     * @since 7
4301e934351Sopenharmony_ci     */
4311e934351Sopenharmony_ci    /**
4321e934351Sopenharmony_ci     * Port number. The value ranges from 0 to 65535.
4331e934351Sopenharmony_ci     * @type {number}
4341e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4351e934351Sopenharmony_ci     * @crossplatform
4361e934351Sopenharmony_ci     * @since 10
4371e934351Sopenharmony_ci     */
4381e934351Sopenharmony_ci    port: number;
4391e934351Sopenharmony_ci
4401e934351Sopenharmony_ci    /**
4411e934351Sopenharmony_ci     * Length of the server response message, in bytes.
4421e934351Sopenharmony_ci     * @type {number}
4431e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4441e934351Sopenharmony_ci     * @since 7
4451e934351Sopenharmony_ci     */
4461e934351Sopenharmony_ci    /**
4471e934351Sopenharmony_ci     * Length of the server response message, in bytes.
4481e934351Sopenharmony_ci     * @type {number}
4491e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4501e934351Sopenharmony_ci     * @crossplatform
4511e934351Sopenharmony_ci     * @since 10
4521e934351Sopenharmony_ci     */
4531e934351Sopenharmony_ci    size: number;
4541e934351Sopenharmony_ci  }
4551e934351Sopenharmony_ci
4561e934351Sopenharmony_ci  /**
4571e934351Sopenharmony_ci   * Defines the local socket connection information.
4581e934351Sopenharmony_ci   * @interface LocalSocketMessageInfo
4591e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
4601e934351Sopenharmony_ci   * @since 11
4611e934351Sopenharmony_ci   */
4621e934351Sopenharmony_ci  /**
4631e934351Sopenharmony_ci   * Defines the local socket connection information.
4641e934351Sopenharmony_ci   * @interface LocalSocketMessageInfo
4651e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
4661e934351Sopenharmony_ci   * @crossplatform
4671e934351Sopenharmony_ci   * @since 12
4681e934351Sopenharmony_ci   */
4691e934351Sopenharmony_ci  export interface LocalSocketMessageInfo {
4701e934351Sopenharmony_ci    /**
4711e934351Sopenharmony_ci     * Message data.
4721e934351Sopenharmony_ci     * @type {ArrayBuffer}
4731e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4741e934351Sopenharmony_ci     * @since 11
4751e934351Sopenharmony_ci     */
4761e934351Sopenharmony_ci    /**
4771e934351Sopenharmony_ci     * Message data.
4781e934351Sopenharmony_ci     * @type {ArrayBuffer}
4791e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4801e934351Sopenharmony_ci     * @crossplatform
4811e934351Sopenharmony_ci     * @since 12
4821e934351Sopenharmony_ci     */
4831e934351Sopenharmony_ci    message: ArrayBuffer;
4841e934351Sopenharmony_ci
4851e934351Sopenharmony_ci    /**
4861e934351Sopenharmony_ci     * Bound local socket address.
4871e934351Sopenharmony_ci     * @type {string}
4881e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4891e934351Sopenharmony_ci     * @since 11
4901e934351Sopenharmony_ci     */
4911e934351Sopenharmony_ci    /**
4921e934351Sopenharmony_ci     * Bound local socket address.
4931e934351Sopenharmony_ci     * @type {string}
4941e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
4951e934351Sopenharmony_ci     * @crossplatform
4961e934351Sopenharmony_ci     * @since 12
4971e934351Sopenharmony_ci     */
4981e934351Sopenharmony_ci    address: string;
4991e934351Sopenharmony_ci
5001e934351Sopenharmony_ci    /**
5011e934351Sopenharmony_ci     * Length of the message, in bytes.
5021e934351Sopenharmony_ci     * @type {number}
5031e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5041e934351Sopenharmony_ci     * @since 11
5051e934351Sopenharmony_ci     */
5061e934351Sopenharmony_ci    /**
5071e934351Sopenharmony_ci     * Length of the message, in bytes.
5081e934351Sopenharmony_ci     * @type {number}
5091e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5101e934351Sopenharmony_ci     * @crossplatform
5111e934351Sopenharmony_ci     * @since 12
5121e934351Sopenharmony_ci     */
5131e934351Sopenharmony_ci    size: number;
5141e934351Sopenharmony_ci  }
5151e934351Sopenharmony_ci
5161e934351Sopenharmony_ci  /**
5171e934351Sopenharmony_ci   * Defines a local address.
5181e934351Sopenharmony_ci   * @interface LocalAddress
5191e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
5201e934351Sopenharmony_ci   * @since 11
5211e934351Sopenharmony_ci   */
5221e934351Sopenharmony_ci  /**
5231e934351Sopenharmony_ci   * Defines a local address.
5241e934351Sopenharmony_ci   * @interface LocalAddress
5251e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
5261e934351Sopenharmony_ci   * @crossplatform
5271e934351Sopenharmony_ci   * @since 12
5281e934351Sopenharmony_ci   */
5291e934351Sopenharmony_ci  export interface LocalAddress {
5301e934351Sopenharmony_ci    /**
5311e934351Sopenharmony_ci     * LocalAddress address.
5321e934351Sopenharmony_ci     * @type {string}
5331e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5341e934351Sopenharmony_ci     * @since 11
5351e934351Sopenharmony_ci     */
5361e934351Sopenharmony_ci    /**
5371e934351Sopenharmony_ci     * LocalAddress address.
5381e934351Sopenharmony_ci     * @type {string}
5391e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5401e934351Sopenharmony_ci     * @crossplatform
5411e934351Sopenharmony_ci     * @since 12
5421e934351Sopenharmony_ci     */
5431e934351Sopenharmony_ci    address: string;
5441e934351Sopenharmony_ci  }
5451e934351Sopenharmony_ci
5461e934351Sopenharmony_ci  /**
5471e934351Sopenharmony_ci   * Defines LocalSocket connection parameters.
5481e934351Sopenharmony_ci   * @interface LocalConnectOptions
5491e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
5501e934351Sopenharmony_ci   * @since 11
5511e934351Sopenharmony_ci   */
5521e934351Sopenharmony_ci  /**
5531e934351Sopenharmony_ci   * Defines LocalSocket connection parameters.
5541e934351Sopenharmony_ci   * @interface LocalConnectOptions
5551e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
5561e934351Sopenharmony_ci   * @crossplatform
5571e934351Sopenharmony_ci   * @since 12
5581e934351Sopenharmony_ci   */
5591e934351Sopenharmony_ci  export interface LocalConnectOptions {
5601e934351Sopenharmony_ci    /**
5611e934351Sopenharmony_ci     * Bound Local address.
5621e934351Sopenharmony_ci     * @type {LocalAddress}
5631e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5641e934351Sopenharmony_ci     * @since 11
5651e934351Sopenharmony_ci     */
5661e934351Sopenharmony_ci    /**
5671e934351Sopenharmony_ci     * Bound Local address.
5681e934351Sopenharmony_ci     * @type {LocalAddress}
5691e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5701e934351Sopenharmony_ci     * @crossplatform
5711e934351Sopenharmony_ci     * @since 12
5721e934351Sopenharmony_ci     */
5731e934351Sopenharmony_ci    address: LocalAddress;
5741e934351Sopenharmony_ci
5751e934351Sopenharmony_ci    /**
5761e934351Sopenharmony_ci     * Timeout duration of the LocalSocket connection, in milliseconds.
5771e934351Sopenharmony_ci     * @type {?number}
5781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5791e934351Sopenharmony_ci     * @since 11
5801e934351Sopenharmony_ci     */
5811e934351Sopenharmony_ci    /**
5821e934351Sopenharmony_ci     * Timeout duration of the LocalSocket connection, in milliseconds.
5831e934351Sopenharmony_ci     * @type {?number}
5841e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
5851e934351Sopenharmony_ci     * @crossplatform
5861e934351Sopenharmony_ci     * @since 12
5871e934351Sopenharmony_ci     */
5881e934351Sopenharmony_ci    timeout?: number;
5891e934351Sopenharmony_ci  }
5901e934351Sopenharmony_ci
5911e934351Sopenharmony_ci  /**
5921e934351Sopenharmony_ci   * Defines the parameters for sending data over the LocalSocket connection.
5931e934351Sopenharmony_ci   * @interface LocalSendOptions
5941e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
5951e934351Sopenharmony_ci   * @since 11
5961e934351Sopenharmony_ci   */
5971e934351Sopenharmony_ci  /**
5981e934351Sopenharmony_ci   * Defines the parameters for sending data over the LocalSocket connection.
5991e934351Sopenharmony_ci   * @interface LocalSendOptions
6001e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
6011e934351Sopenharmony_ci   * @crossplatform
6021e934351Sopenharmony_ci   * @since 12
6031e934351Sopenharmony_ci   */
6041e934351Sopenharmony_ci  export interface LocalSendOptions {
6051e934351Sopenharmony_ci    /**
6061e934351Sopenharmony_ci     * Data to send.
6071e934351Sopenharmony_ci     * @type {string | ArrayBuffer}
6081e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6091e934351Sopenharmony_ci     * @since 11
6101e934351Sopenharmony_ci     */
6111e934351Sopenharmony_ci    /**
6121e934351Sopenharmony_ci     * Data to send.
6131e934351Sopenharmony_ci     * @type {string | ArrayBuffer}
6141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6151e934351Sopenharmony_ci     * @crossplatform
6161e934351Sopenharmony_ci     * @since 12
6171e934351Sopenharmony_ci     */
6181e934351Sopenharmony_ci    data: string | ArrayBuffer;
6191e934351Sopenharmony_ci
6201e934351Sopenharmony_ci    /**
6211e934351Sopenharmony_ci     * Character encoding format.
6221e934351Sopenharmony_ci     * @type {?string}
6231e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6241e934351Sopenharmony_ci     * @since 11
6251e934351Sopenharmony_ci     */
6261e934351Sopenharmony_ci    /**
6271e934351Sopenharmony_ci     * Character encoding format.
6281e934351Sopenharmony_ci     * @type {?string}
6291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6301e934351Sopenharmony_ci     * @crossplatform
6311e934351Sopenharmony_ci     * @since 12
6321e934351Sopenharmony_ci     */
6331e934351Sopenharmony_ci    encoding?: string;
6341e934351Sopenharmony_ci  }
6351e934351Sopenharmony_ci
6361e934351Sopenharmony_ci  /**
6371e934351Sopenharmony_ci   * Defines a UDPSocket connection.
6381e934351Sopenharmony_ci   * @interface UDPSocket
6391e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
6401e934351Sopenharmony_ci   * @since 7
6411e934351Sopenharmony_ci   */
6421e934351Sopenharmony_ci  /**
6431e934351Sopenharmony_ci   * Defines a UDPSocket connection.
6441e934351Sopenharmony_ci   * @interface UDPSocket
6451e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
6461e934351Sopenharmony_ci   * @crossplatform
6471e934351Sopenharmony_ci   * @since 10
6481e934351Sopenharmony_ci   */
6491e934351Sopenharmony_ci  export interface UDPSocket {
6501e934351Sopenharmony_ci    /**
6511e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
6521e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6531e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
6541e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
6551e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6561e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6571e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6581e934351Sopenharmony_ci     * @since 7
6591e934351Sopenharmony_ci     */
6601e934351Sopenharmony_ci    /**
6611e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
6621e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6631e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
6641e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
6651e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6661e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6671e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6681e934351Sopenharmony_ci     * @crossplatform
6691e934351Sopenharmony_ci     * @since 10
6701e934351Sopenharmony_ci     */
6711e934351Sopenharmony_ci    bind(address: NetAddress, callback: AsyncCallback<void>): void;
6721e934351Sopenharmony_ci
6731e934351Sopenharmony_ci    /**
6741e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
6751e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6761e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
6771e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
6781e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6791e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6801e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6811e934351Sopenharmony_ci     * @since 7
6821e934351Sopenharmony_ci     */
6831e934351Sopenharmony_ci    /**
6841e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
6851e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
6861e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
6871e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
6881e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
6891e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
6901e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
6911e934351Sopenharmony_ci     * @crossplatform
6921e934351Sopenharmony_ci     * @since 10
6931e934351Sopenharmony_ci     */
6941e934351Sopenharmony_ci    bind(address: NetAddress): Promise<void>;
6951e934351Sopenharmony_ci
6961e934351Sopenharmony_ci    /**
6971e934351Sopenharmony_ci     * Obtains the local address of a UDPSocket connection.
6981e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
6991e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
7001e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
7011e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
7021e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7031e934351Sopenharmony_ci     * @since 12
7041e934351Sopenharmony_ci     */
7051e934351Sopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
7061e934351Sopenharmony_ci
7071e934351Sopenharmony_ci    /**
7081e934351Sopenharmony_ci     * Sends data over a UDPSocket connection.
7091e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7101e934351Sopenharmony_ci     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
7111e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
7121e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
7131e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7151e934351Sopenharmony_ci     * @since 7
7161e934351Sopenharmony_ci     */
7171e934351Sopenharmony_ci    /**
7181e934351Sopenharmony_ci     * Sends data over a UDPSocket connection.
7191e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7201e934351Sopenharmony_ci     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
7211e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
7221e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
7231e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7241e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7251e934351Sopenharmony_ci     * @crossplatform
7261e934351Sopenharmony_ci     * @since 10
7271e934351Sopenharmony_ci     */
7281e934351Sopenharmony_ci    send(options: UDPSendOptions, callback: AsyncCallback<void>): void;
7291e934351Sopenharmony_ci
7301e934351Sopenharmony_ci    /**
7311e934351Sopenharmony_ci     * Sends data over a UDPSocket connection.
7321e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7331e934351Sopenharmony_ci     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
7341e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
7351e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
7361e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7371e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7381e934351Sopenharmony_ci     * @since 7
7391e934351Sopenharmony_ci     */
7401e934351Sopenharmony_ci    /**
7411e934351Sopenharmony_ci     * Sends data over a UDPSocket connection.
7421e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7431e934351Sopenharmony_ci     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
7441e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
7451e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
7461e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7471e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7481e934351Sopenharmony_ci     * @crossplatform
7491e934351Sopenharmony_ci     * @since 10
7501e934351Sopenharmony_ci     */
7511e934351Sopenharmony_ci    send(options: UDPSendOptions): Promise<void>;
7521e934351Sopenharmony_ci
7531e934351Sopenharmony_ci    /**
7541e934351Sopenharmony_ci     * Closes a UDPSocket connection.
7551e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7561e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
7571e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7591e934351Sopenharmony_ci     * @since 7
7601e934351Sopenharmony_ci     */
7611e934351Sopenharmony_ci    /**
7621e934351Sopenharmony_ci     * Closes a UDPSocket connection.
7631e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7641e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
7651e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7661e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7671e934351Sopenharmony_ci     * @crossplatform
7681e934351Sopenharmony_ci     * @since 10
7691e934351Sopenharmony_ci     */
7701e934351Sopenharmony_ci    close(callback: AsyncCallback<void>): void;
7711e934351Sopenharmony_ci
7721e934351Sopenharmony_ci    /**
7731e934351Sopenharmony_ci     * Closes a UDPSocket connection.
7741e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7751e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
7761e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7771e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7781e934351Sopenharmony_ci     * @since 7
7791e934351Sopenharmony_ci     */
7801e934351Sopenharmony_ci    /**
7811e934351Sopenharmony_ci     * Closes a UDPSocket connection.
7821e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7831e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
7841e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7851e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7861e934351Sopenharmony_ci     * @crossplatform
7871e934351Sopenharmony_ci     * @since 10
7881e934351Sopenharmony_ci     */
7891e934351Sopenharmony_ci    close(): Promise<void>;
7901e934351Sopenharmony_ci
7911e934351Sopenharmony_ci    /**
7921e934351Sopenharmony_ci     * Obtains the status of the UDPSocket connection.
7931e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
7941e934351Sopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}.
7951e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
7961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
7971e934351Sopenharmony_ci     * @since 7
7981e934351Sopenharmony_ci     */
7991e934351Sopenharmony_ci    /**
8001e934351Sopenharmony_ci     * Obtains the status of the UDPSocket connection.
8011e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
8021e934351Sopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}.
8031e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
8041e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8051e934351Sopenharmony_ci     * @crossplatform
8061e934351Sopenharmony_ci     * @since 10
8071e934351Sopenharmony_ci     */
8081e934351Sopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
8091e934351Sopenharmony_ci
8101e934351Sopenharmony_ci    /**
8111e934351Sopenharmony_ci     * Obtains the status of the UDPSocket connection.
8121e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
8131e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
8141e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
8151e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8161e934351Sopenharmony_ci     * @since 7
8171e934351Sopenharmony_ci     */
8181e934351Sopenharmony_ci    /**
8191e934351Sopenharmony_ci     * Obtains the status of the UDPSocket connection.
8201e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
8211e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
8221e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
8231e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8241e934351Sopenharmony_ci     * @crossplatform
8251e934351Sopenharmony_ci     * @since 10
8261e934351Sopenharmony_ci     */
8271e934351Sopenharmony_ci    getState(): Promise<SocketStateBase>;
8281e934351Sopenharmony_ci
8291e934351Sopenharmony_ci    /**
8301e934351Sopenharmony_ci     * Sets other attributes of the UDPSocket connection.
8311e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
8321e934351Sopenharmony_ci     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
8331e934351Sopenharmony_ci     * @param { AsyncCallback<void> }callback - the callback of setExtraOptions.
8341e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
8351e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
8361e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8371e934351Sopenharmony_ci     * @since 7
8381e934351Sopenharmony_ci     */
8391e934351Sopenharmony_ci    /**
8401e934351Sopenharmony_ci     * Sets other attributes of the UDPSocket connection.
8411e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
8421e934351Sopenharmony_ci     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
8431e934351Sopenharmony_ci     * @param { AsyncCallback<void> }callback - the callback of setExtraOptions.
8441e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
8451e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
8461e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8471e934351Sopenharmony_ci     * @crossplatform
8481e934351Sopenharmony_ci     * @since 10
8491e934351Sopenharmony_ci     */
8501e934351Sopenharmony_ci    setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback<void>): void;
8511e934351Sopenharmony_ci
8521e934351Sopenharmony_ci    /**
8531e934351Sopenharmony_ci     * Sets other attributes of the UDPSocket connection.
8541e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
8551e934351Sopenharmony_ci     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
8561e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
8571e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
8581e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
8591e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8601e934351Sopenharmony_ci     * @since 7
8611e934351Sopenharmony_ci     */
8621e934351Sopenharmony_ci    /**
8631e934351Sopenharmony_ci     * Sets other attributes of the UDPSocket connection.
8641e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
8651e934351Sopenharmony_ci     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
8661e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
8671e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
8681e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
8691e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8701e934351Sopenharmony_ci     * @crossplatform
8711e934351Sopenharmony_ci     * @since 10
8721e934351Sopenharmony_ci     */
8731e934351Sopenharmony_ci    setExtraOptions(options: UDPExtraOptions): Promise<void>;
8741e934351Sopenharmony_ci
8751e934351Sopenharmony_ci    /**
8761e934351Sopenharmony_ci     * Listens for message receiving events of the UDPSocket connection.
8771e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
8781e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
8791e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8801e934351Sopenharmony_ci     * @since 7
8811e934351Sopenharmony_ci     */
8821e934351Sopenharmony_ci    /**
8831e934351Sopenharmony_ci     * Listens for message receiving events of the UDPSocket connection.
8841e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
8851e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
8861e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8871e934351Sopenharmony_ci     * @crossplatform
8881e934351Sopenharmony_ci     * @since 10
8891e934351Sopenharmony_ci     */
8901e934351Sopenharmony_ci    /**
8911e934351Sopenharmony_ci     * Listens for message receiving events of the UDPSocket connection.
8921e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
8931e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
8941e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
8951e934351Sopenharmony_ci     * @crossplatform
8961e934351Sopenharmony_ci     * @since 11
8971e934351Sopenharmony_ci     */
8981e934351Sopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
8991e934351Sopenharmony_ci
9001e934351Sopenharmony_ci    /**
9011e934351Sopenharmony_ci     * Cancels listening for message receiving events of the UDPSocket connection.
9021e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
9031e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
9041e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9051e934351Sopenharmony_ci     * @since 7
9061e934351Sopenharmony_ci     */
9071e934351Sopenharmony_ci    /**
9081e934351Sopenharmony_ci     * Cancels listening for message receiving events of the UDPSocket connection.
9091e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
9101e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
9111e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9121e934351Sopenharmony_ci     * @crossplatform
9131e934351Sopenharmony_ci     * @since 10
9141e934351Sopenharmony_ci     */
9151e934351Sopenharmony_ci    /**
9161e934351Sopenharmony_ci     * Cancels listening for message receiving events of the UDPSocket connection.
9171e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
9181e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
9191e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9201e934351Sopenharmony_ci     * @crossplatform
9211e934351Sopenharmony_ci     * @since 11
9221e934351Sopenharmony_ci     */
9231e934351Sopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
9241e934351Sopenharmony_ci
9251e934351Sopenharmony_ci    /**
9261e934351Sopenharmony_ci     * Listens for data packet message events or close events of the UDPSocket connection.
9271e934351Sopenharmony_ci     * @param { 'listening' | 'close' } type - Indicates Event name.
9281e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
9291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9301e934351Sopenharmony_ci     * @since 7
9311e934351Sopenharmony_ci     */
9321e934351Sopenharmony_ci    /**
9331e934351Sopenharmony_ci     * Listens for data packet message events or close events of the UDPSocket connection.
9341e934351Sopenharmony_ci     * @param { 'listening' | 'close' } type - Indicates Event name.
9351e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
9361e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9371e934351Sopenharmony_ci     * @crossplatform
9381e934351Sopenharmony_ci     * @since 10
9391e934351Sopenharmony_ci     */
9401e934351Sopenharmony_ci    on(type: 'listening' | 'close', callback: Callback<void>): void;
9411e934351Sopenharmony_ci
9421e934351Sopenharmony_ci    /**
9431e934351Sopenharmony_ci     * Cancels listening for data packet message events or close events of the UDPSocket connection.
9441e934351Sopenharmony_ci     * @param { 'listening' | 'close' } type - Indicates Event name.
9451e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
9461e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9471e934351Sopenharmony_ci     * @since 7
9481e934351Sopenharmony_ci     */
9491e934351Sopenharmony_ci    /**
9501e934351Sopenharmony_ci     * Cancels listening for data packet message events or close events of the UDPSocket connection.
9511e934351Sopenharmony_ci     * @param { 'listening' | 'close' } type - Indicates Event name.
9521e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
9531e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9541e934351Sopenharmony_ci     * @crossplatform
9551e934351Sopenharmony_ci     * @since 10
9561e934351Sopenharmony_ci     */
9571e934351Sopenharmony_ci    off(type: 'listening' | 'close', callback?: Callback<void>): void;
9581e934351Sopenharmony_ci
9591e934351Sopenharmony_ci    /**
9601e934351Sopenharmony_ci     * Listens for error events of the UDPSocket connection.
9611e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
9621e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9631e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9641e934351Sopenharmony_ci     * @since 7
9651e934351Sopenharmony_ci     */
9661e934351Sopenharmony_ci    /**
9671e934351Sopenharmony_ci     * Listens for error events of the UDPSocket connection.
9681e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
9691e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9701e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9711e934351Sopenharmony_ci     * @crossplatform
9721e934351Sopenharmony_ci     * @since 10
9731e934351Sopenharmony_ci     */
9741e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
9751e934351Sopenharmony_ci
9761e934351Sopenharmony_ci    /**
9771e934351Sopenharmony_ci     * Cancels listening for error events of the UDPSocket connection.
9781e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
9791e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9801e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9811e934351Sopenharmony_ci     * @since 7
9821e934351Sopenharmony_ci     */
9831e934351Sopenharmony_ci    /**
9841e934351Sopenharmony_ci     * Cancels listening for error events of the UDPSocket connection.
9851e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
9861e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
9871e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
9881e934351Sopenharmony_ci     * @crossplatform
9891e934351Sopenharmony_ci     * @since 10
9901e934351Sopenharmony_ci     */
9911e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
9921e934351Sopenharmony_ci  }
9931e934351Sopenharmony_ci
9941e934351Sopenharmony_ci  /**
9951e934351Sopenharmony_ci   * Defines a UDP MulticastSocket connection.
9961e934351Sopenharmony_ci   * @interface MulticastSocket
9971e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
9981e934351Sopenharmony_ci   * @since 11
9991e934351Sopenharmony_ci   */
10001e934351Sopenharmony_ci  /**
10011e934351Sopenharmony_ci   * Defines a UDP MulticastSocket connection.
10021e934351Sopenharmony_ci   * @interface MulticastSocket
10031e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
10041e934351Sopenharmony_ci   * @crossplatform
10051e934351Sopenharmony_ci   * @since 12
10061e934351Sopenharmony_ci   */
10071e934351Sopenharmony_ci  export interface MulticastSocket extends UDPSocket {
10081e934351Sopenharmony_ci    /**
10091e934351Sopenharmony_ci     * Add the socket to the multicast group.
10101e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
10111e934351Sopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
10121e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of addMembership.
10131e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
10141e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
10151e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
10161e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
10171e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
10181e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
10191e934351Sopenharmony_ci     * @since 11
10201e934351Sopenharmony_ci     */
10211e934351Sopenharmony_ci    /**
10221e934351Sopenharmony_ci     * Add the socket to the multicast group.
10231e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
10241e934351Sopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
10251e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of addMembership.
10261e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
10271e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
10281e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
10291e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
10301e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
10311e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
10321e934351Sopenharmony_ci     * @crossplatform
10331e934351Sopenharmony_ci     * @since 12
10341e934351Sopenharmony_ci     */
10351e934351Sopenharmony_ci    addMembership(multicastAddress: NetAddress, callback: AsyncCallback<void>): void;
10361e934351Sopenharmony_ci
10371e934351Sopenharmony_ci    /**
10381e934351Sopenharmony_ci     * Add the socket to the multicast group.
10391e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
10401e934351Sopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
10411e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
10421e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
10431e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
10441e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
10451e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
10461e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
10471e934351Sopenharmony_ci     * @since 11
10481e934351Sopenharmony_ci     */
10491e934351Sopenharmony_ci    /**
10501e934351Sopenharmony_ci     * Add the socket to the multicast group.
10511e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
10521e934351Sopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
10531e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
10541e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
10551e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
10561e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
10571e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
10581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
10591e934351Sopenharmony_ci     * @crossplatform
10601e934351Sopenharmony_ci     * @since 12
10611e934351Sopenharmony_ci     */
10621e934351Sopenharmony_ci    addMembership(multicastAddress: NetAddress): Promise<void>;
10631e934351Sopenharmony_ci
10641e934351Sopenharmony_ci    /**
10651e934351Sopenharmony_ci     * Drop the socket from the multicast group.
10661e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
10671e934351Sopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
10681e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of dropMembership.
10691e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
10701e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
10711e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
10721e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
10731e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
10741e934351Sopenharmony_ci     * @since 11
10751e934351Sopenharmony_ci     */
10761e934351Sopenharmony_ci    /**
10771e934351Sopenharmony_ci     * Drop the socket from the multicast group.
10781e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
10791e934351Sopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
10801e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of dropMembership.
10811e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
10821e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
10831e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
10841e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
10851e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
10861e934351Sopenharmony_ci     * @crossplatform
10871e934351Sopenharmony_ci     * @since 12
10881e934351Sopenharmony_ci     */
10891e934351Sopenharmony_ci    dropMembership(multicastAddress: NetAddress, callback: AsyncCallback<void>): void;
10901e934351Sopenharmony_ci
10911e934351Sopenharmony_ci    /**
10921e934351Sopenharmony_ci     * Drop the socket from the multicast group.
10931e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
10941e934351Sopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
10951e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
10961e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
10971e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
10981e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
10991e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
11001e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11011e934351Sopenharmony_ci     * @since 11
11021e934351Sopenharmony_ci     */
11031e934351Sopenharmony_ci    /**
11041e934351Sopenharmony_ci     * Drop the socket from the multicast group.
11051e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
11061e934351Sopenharmony_ci     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
11071e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
11081e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
11091e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11101e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11111e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address in use.
11121e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11131e934351Sopenharmony_ci     * @crossplatform
11141e934351Sopenharmony_ci     * @since 12
11151e934351Sopenharmony_ci     */
11161e934351Sopenharmony_ci    dropMembership(multicastAddress: NetAddress): Promise<void>;
11171e934351Sopenharmony_ci
11181e934351Sopenharmony_ci    /**
11191e934351Sopenharmony_ci     * Set the TTL value for socket multicast packets.
11201e934351Sopenharmony_ci     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
11211e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setMulticastTTL.
11221e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11231e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
11241e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11251e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11261e934351Sopenharmony_ci     * @since 11
11271e934351Sopenharmony_ci     */
11281e934351Sopenharmony_ci    /**
11291e934351Sopenharmony_ci     * Set the TTL value for socket multicast packets.
11301e934351Sopenharmony_ci     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
11311e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setMulticastTTL.
11321e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11331e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
11341e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11351e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11361e934351Sopenharmony_ci     * @crossplatform
11371e934351Sopenharmony_ci     * @since 12
11381e934351Sopenharmony_ci     */
11391e934351Sopenharmony_ci    setMulticastTTL(ttl: number, callback: AsyncCallback<void>): void;
11401e934351Sopenharmony_ci
11411e934351Sopenharmony_ci    /**
11421e934351Sopenharmony_ci     * Set the TTL value for socket multicast packet.
11431e934351Sopenharmony_ci     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
11441e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
11451e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11461e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
11471e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11481e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11491e934351Sopenharmony_ci     * @since 11
11501e934351Sopenharmony_ci     */
11511e934351Sopenharmony_ci    /**
11521e934351Sopenharmony_ci     * Set the TTL value for socket multicast packet.
11531e934351Sopenharmony_ci     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
11541e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
11551e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11561e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
11571e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11591e934351Sopenharmony_ci     * @crossplatform
11601e934351Sopenharmony_ci     * @since 12
11611e934351Sopenharmony_ci     */
11621e934351Sopenharmony_ci    setMulticastTTL(ttl: number): Promise<void>;
11631e934351Sopenharmony_ci
11641e934351Sopenharmony_ci    /**
11651e934351Sopenharmony_ci     * Get the TTL value of socket multicast packet.
11661e934351Sopenharmony_ci     * @param { AsyncCallback<number> } callback - The callback of getMulticastTTL.
11671e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11681e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11691e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11701e934351Sopenharmony_ci     * @since 11
11711e934351Sopenharmony_ci     */
11721e934351Sopenharmony_ci    /**
11731e934351Sopenharmony_ci     * Get the TTL value of socket multicast packet.
11741e934351Sopenharmony_ci     * @param { AsyncCallback<number> } callback - The callback of getMulticastTTL.
11751e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11761e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11771e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11781e934351Sopenharmony_ci     * @crossplatform
11791e934351Sopenharmony_ci     * @since 12
11801e934351Sopenharmony_ci     */
11811e934351Sopenharmony_ci    getMulticastTTL(callback: AsyncCallback<number>): void;
11821e934351Sopenharmony_ci
11831e934351Sopenharmony_ci    /**
11841e934351Sopenharmony_ci     * Get the TTL value of socket multicast packet.
11851e934351Sopenharmony_ci     * @returns { Promise<number> } The promise returned by the function.
11861e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11871e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11881e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11891e934351Sopenharmony_ci     * @since 11
11901e934351Sopenharmony_ci     */
11911e934351Sopenharmony_ci    /**
11921e934351Sopenharmony_ci     * Get the TTL value of socket multicast packet.
11931e934351Sopenharmony_ci     * @returns { Promise<number> } The promise returned by the function.
11941e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
11951e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
11961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
11971e934351Sopenharmony_ci     * @crossplatform
11981e934351Sopenharmony_ci     * @since 12
11991e934351Sopenharmony_ci     */
12001e934351Sopenharmony_ci    getMulticastTTL(): Promise<number>;
12011e934351Sopenharmony_ci
12021e934351Sopenharmony_ci    /**
12031e934351Sopenharmony_ci     * Set the loopback mode for the socket.
12041e934351Sopenharmony_ci     * @param { boolean } flag - Whether to enable loopback mode.
12051e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setLoopbackMode.
12061e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
12071e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
12081e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
12091e934351Sopenharmony_ci     * @since 11
12101e934351Sopenharmony_ci     */
12111e934351Sopenharmony_ci    /**
12121e934351Sopenharmony_ci     * Set the loopback mode for the socket.
12131e934351Sopenharmony_ci     * @param { boolean } flag - Whether to enable loopback mode.
12141e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setLoopbackMode.
12151e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
12161e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
12171e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
12181e934351Sopenharmony_ci     * @crossplatform
12191e934351Sopenharmony_ci     * @since 12
12201e934351Sopenharmony_ci     */
12211e934351Sopenharmony_ci    setLoopbackMode(flag: boolean, callback: AsyncCallback<void>): void;
12221e934351Sopenharmony_ci
12231e934351Sopenharmony_ci    /**
12241e934351Sopenharmony_ci     * Set the loopback mode for the socket.
12251e934351Sopenharmony_ci     * @param { boolean } flag - Whether to enable loopback mode.
12261e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
12271e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
12281e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
12291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
12301e934351Sopenharmony_ci     * @since 11
12311e934351Sopenharmony_ci     */
12321e934351Sopenharmony_ci    /**
12331e934351Sopenharmony_ci     * Set the loopback mode for the socket.
12341e934351Sopenharmony_ci     * @param { boolean } flag - Whether to enable loopback mode.
12351e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
12361e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
12371e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
12381e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
12391e934351Sopenharmony_ci     * @crossplatform
12401e934351Sopenharmony_ci     * @since 12
12411e934351Sopenharmony_ci     */
12421e934351Sopenharmony_ci    setLoopbackMode(flag: boolean): Promise<void>;
12431e934351Sopenharmony_ci
12441e934351Sopenharmony_ci    /**
12451e934351Sopenharmony_ci     * Get the loopback mode of the socket.
12461e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - The callback of getLoopbackMode.
12471e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
12481e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
12491e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
12501e934351Sopenharmony_ci     * @since 11
12511e934351Sopenharmony_ci     */
12521e934351Sopenharmony_ci    /**
12531e934351Sopenharmony_ci     * Get the loopback mode of the socket.
12541e934351Sopenharmony_ci     * @param { AsyncCallback<boolean> } callback - The callback of getLoopbackMode.
12551e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
12561e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
12571e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
12581e934351Sopenharmony_ci     * @crossplatform
12591e934351Sopenharmony_ci     * @since 12
12601e934351Sopenharmony_ci     */
12611e934351Sopenharmony_ci    getLoopbackMode(callback: AsyncCallback<boolean>): void;
12621e934351Sopenharmony_ci
12631e934351Sopenharmony_ci    /**
12641e934351Sopenharmony_ci     * Get the loopback mode of the socket.
12651e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
12661e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
12671e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
12681e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
12691e934351Sopenharmony_ci     * @since 11
12701e934351Sopenharmony_ci     */
12711e934351Sopenharmony_ci    /**
12721e934351Sopenharmony_ci     * Get the loopback mode of the socket.
12731e934351Sopenharmony_ci     * @returns { Promise<boolean> } The promise returned by the function.
12741e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
12751e934351Sopenharmony_ci     * @throws { BusinessError } 2301088 - Not a socket.
12761e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
12771e934351Sopenharmony_ci     * @crossplatform
12781e934351Sopenharmony_ci     * @since 12
12791e934351Sopenharmony_ci     */
12801e934351Sopenharmony_ci    getLoopbackMode(): Promise<boolean>;
12811e934351Sopenharmony_ci  }
12821e934351Sopenharmony_ci
12831e934351Sopenharmony_ci  /**
12841e934351Sopenharmony_ci   * Defines a LocalSocket connection.
12851e934351Sopenharmony_ci   * @interface LocalSocket
12861e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
12871e934351Sopenharmony_ci   * @since 11
12881e934351Sopenharmony_ci   */
12891e934351Sopenharmony_ci  /**
12901e934351Sopenharmony_ci   * Defines a LocalSocket connection.
12911e934351Sopenharmony_ci   * @interface LocalSocket
12921e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
12931e934351Sopenharmony_ci   * @crossplatform
12941e934351Sopenharmony_ci   * @since 12
12951e934351Sopenharmony_ci   */
12961e934351Sopenharmony_ci  export interface LocalSocket {
12971e934351Sopenharmony_ci    /**
12981e934351Sopenharmony_ci     * Binds the Local address.
12991e934351Sopenharmony_ci     * @param { LocalAddress } address - Destination address. {@link LocalAddress}
13001e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
13011e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
13021e934351Sopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
13031e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
13041e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address already in use.
13051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13061e934351Sopenharmony_ci     * @since 11
13071e934351Sopenharmony_ci     */
13081e934351Sopenharmony_ci    /**
13091e934351Sopenharmony_ci     * Binds the Local address.
13101e934351Sopenharmony_ci     * @param { LocalAddress } address - Destination address. {@link LocalAddress}
13111e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
13121e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
13131e934351Sopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
13141e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
13151e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address already in use.
13161e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13171e934351Sopenharmony_ci     * @crossplatform
13181e934351Sopenharmony_ci     * @since 12
13191e934351Sopenharmony_ci     */
13201e934351Sopenharmony_ci    bind(address: LocalAddress): Promise<void>;
13211e934351Sopenharmony_ci
13221e934351Sopenharmony_ci    /**
13231e934351Sopenharmony_ci     * Sets up a connection to the specified Local address .
13241e934351Sopenharmony_ci     * @param { LocalConnectOptions } options - Optional parameters {@link LocalConnectOptions}.
13251e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
13261e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
13271e934351Sopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
13281e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
13291e934351Sopenharmony_ci     * @throws { BusinessError } 2301111 - Connection refused.
13301e934351Sopenharmony_ci     * @throws { BusinessError } 2301099 - Cannot assign requested address.
13311e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13321e934351Sopenharmony_ci     * @since 11
13331e934351Sopenharmony_ci     */
13341e934351Sopenharmony_ci    /**
13351e934351Sopenharmony_ci     * Sets up a connection to the specified Local address .
13361e934351Sopenharmony_ci     * @param { LocalConnectOptions } options - Optional parameters {@link LocalConnectOptions}.
13371e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
13381e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
13391e934351Sopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
13401e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
13411e934351Sopenharmony_ci     * @throws { BusinessError } 2301111 - Connection refused.
13421e934351Sopenharmony_ci     * @throws { BusinessError } 2301099 - Cannot assign requested address.
13431e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13441e934351Sopenharmony_ci     * @crossplatform
13451e934351Sopenharmony_ci     * @since 12
13461e934351Sopenharmony_ci     */
13471e934351Sopenharmony_ci    connect(options: LocalConnectOptions): Promise<void>;
13481e934351Sopenharmony_ci
13491e934351Sopenharmony_ci    /**
13501e934351Sopenharmony_ci     * Sends data over a LocalSocket connection.
13511e934351Sopenharmony_ci     * @param { LocalSendOptions } options - Optional parameters {@link LocalSendOptions}.
13521e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
13531e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
13541e934351Sopenharmony_ci     * @throws { BusinessError } 2301011 - Operation would block.
13551e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13561e934351Sopenharmony_ci     * @since 11
13571e934351Sopenharmony_ci     */
13581e934351Sopenharmony_ci    /**
13591e934351Sopenharmony_ci     * Sends data over a LocalSocket connection.
13601e934351Sopenharmony_ci     * @param { LocalSendOptions } options - Optional parameters {@link LocalSendOptions}.
13611e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
13621e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
13631e934351Sopenharmony_ci     * @throws { BusinessError } 2301011 - Operation would block.
13641e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13651e934351Sopenharmony_ci     * @crossplatform
13661e934351Sopenharmony_ci     * @since 12
13671e934351Sopenharmony_ci     */
13681e934351Sopenharmony_ci    send(options: LocalSendOptions): Promise<void>;
13691e934351Sopenharmony_ci
13701e934351Sopenharmony_ci    /**
13711e934351Sopenharmony_ci     * Closes a LocalSocket connection.
13721e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
13731e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
13741e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13751e934351Sopenharmony_ci     * @since 11
13761e934351Sopenharmony_ci     */
13771e934351Sopenharmony_ci    /**
13781e934351Sopenharmony_ci     * Closes a LocalSocket connection.
13791e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
13801e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
13811e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13821e934351Sopenharmony_ci     * @crossplatform
13831e934351Sopenharmony_ci     * @since 12
13841e934351Sopenharmony_ci     */
13851e934351Sopenharmony_ci    close(): Promise<void>;
13861e934351Sopenharmony_ci
13871e934351Sopenharmony_ci    /**
13881e934351Sopenharmony_ci     * Obtains the status of the LocalSocket connection.
13891e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
13901e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13911e934351Sopenharmony_ci     * @since 11
13921e934351Sopenharmony_ci     */
13931e934351Sopenharmony_ci    /**
13941e934351Sopenharmony_ci     * Obtains the status of the LocalSocket connection.
13951e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
13961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
13971e934351Sopenharmony_ci     * @crossplatform
13981e934351Sopenharmony_ci     * @since 12
13991e934351Sopenharmony_ci     */
14001e934351Sopenharmony_ci    getState(): Promise<SocketStateBase>;
14011e934351Sopenharmony_ci
14021e934351Sopenharmony_ci    /**
14031e934351Sopenharmony_ci     * Obtains the file descriptor of the LocalSocket connection.
14041e934351Sopenharmony_ci     * @returns { Promise<number> } The promise returns the file descriptor of the LocalSocket connection.
14051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14061e934351Sopenharmony_ci     * @since 11
14071e934351Sopenharmony_ci     */
14081e934351Sopenharmony_ci    /**
14091e934351Sopenharmony_ci     * Obtains the file descriptor of the LocalSocket connection.
14101e934351Sopenharmony_ci     * @returns { Promise<number> } The promise returns the file descriptor of the LocalSocket connection.
14111e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14121e934351Sopenharmony_ci     * @crossplatform
14131e934351Sopenharmony_ci     * @since 12
14141e934351Sopenharmony_ci     */
14151e934351Sopenharmony_ci    getSocketFd(): Promise<number>;
14161e934351Sopenharmony_ci
14171e934351Sopenharmony_ci    /**
14181e934351Sopenharmony_ci     * Sets other attributes of the LocalSocket connection.
14191e934351Sopenharmony_ci     * @param { ExtraOptionsBase } options - Optional parameters {@link ExtraOptionsBase}.
14201e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
14211e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
14221e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
14231e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14241e934351Sopenharmony_ci     * @since 11
14251e934351Sopenharmony_ci     */
14261e934351Sopenharmony_ci    /**
14271e934351Sopenharmony_ci     * Sets other attributes of the LocalSocket connection.
14281e934351Sopenharmony_ci     * @param { ExtraOptionsBase } options - Optional parameters {@link ExtraOptionsBase}.
14291e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
14301e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
14311e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
14321e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14331e934351Sopenharmony_ci     * @crossplatform
14341e934351Sopenharmony_ci     * @since 12
14351e934351Sopenharmony_ci     */
14361e934351Sopenharmony_ci    setExtraOptions(options: ExtraOptionsBase): Promise<void>;
14371e934351Sopenharmony_ci
14381e934351Sopenharmony_ci    /**
14391e934351Sopenharmony_ci     * Gets other attributes of the LocalSocket connection.
14401e934351Sopenharmony_ci     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
14411e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
14421e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14431e934351Sopenharmony_ci     * @since 11
14441e934351Sopenharmony_ci     */
14451e934351Sopenharmony_ci    /**
14461e934351Sopenharmony_ci     * Gets other attributes of the LocalSocket connection.
14471e934351Sopenharmony_ci     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
14481e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
14491e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14501e934351Sopenharmony_ci     * @crossplatform
14511e934351Sopenharmony_ci     * @since 12
14521e934351Sopenharmony_ci     */
14531e934351Sopenharmony_ci    getExtraOptions(): Promise<ExtraOptionsBase>;
14541e934351Sopenharmony_ci
14551e934351Sopenharmony_ci    /**
14561e934351Sopenharmony_ci     * Obtains the local address of a LocalSocket connection.
14571e934351Sopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
14581e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
14591e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
14601e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
14611e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14621e934351Sopenharmony_ci     * @since 12
14631e934351Sopenharmony_ci     */
14641e934351Sopenharmony_ci    getLocalAddress(): Promise<string>;
14651e934351Sopenharmony_ci
14661e934351Sopenharmony_ci    /**
14671e934351Sopenharmony_ci     * Listens for message receiving events of the LocalSocket connection.
14681e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
14691e934351Sopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
14701e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
14711e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14721e934351Sopenharmony_ci     * @since 11
14731e934351Sopenharmony_ci     */
14741e934351Sopenharmony_ci    /**
14751e934351Sopenharmony_ci     * Listens for message receiving events of the LocalSocket connection.
14761e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
14771e934351Sopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
14781e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
14791e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14801e934351Sopenharmony_ci     * @crossplatform
14811e934351Sopenharmony_ci     * @since 12
14821e934351Sopenharmony_ci     */
14831e934351Sopenharmony_ci    on(type: 'message', callback: Callback<LocalSocketMessageInfo>): void;
14841e934351Sopenharmony_ci
14851e934351Sopenharmony_ci    /**
14861e934351Sopenharmony_ci     * Cancels listening for message receiving events of the LocalSocket connection.
14871e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
14881e934351Sopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
14891e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
14901e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14911e934351Sopenharmony_ci     * @since 11
14921e934351Sopenharmony_ci     */
14931e934351Sopenharmony_ci    /**
14941e934351Sopenharmony_ci     * Cancels listening for message receiving events of the LocalSocket connection.
14951e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
14961e934351Sopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
14971e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
14981e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
14991e934351Sopenharmony_ci     * @crossplatform
15001e934351Sopenharmony_ci     * @since 12
15011e934351Sopenharmony_ci     */
15021e934351Sopenharmony_ci    off(type: 'message', callback?: Callback<LocalSocketMessageInfo>): void;
15031e934351Sopenharmony_ci
15041e934351Sopenharmony_ci    /**
15051e934351Sopenharmony_ci     * Listens for connection events of the LocalSocket connection.
15061e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
15071e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
15081e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15091e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15101e934351Sopenharmony_ci     * @since 11
15111e934351Sopenharmony_ci     */
15121e934351Sopenharmony_ci    /**
15131e934351Sopenharmony_ci     * Listens for connection events of the LocalSocket connection.
15141e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
15151e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
15161e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15171e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15181e934351Sopenharmony_ci     * @crossplatform
15191e934351Sopenharmony_ci     * @since 12
15201e934351Sopenharmony_ci     */
15211e934351Sopenharmony_ci    on(type: 'connect', callback: Callback<void>): void;
15221e934351Sopenharmony_ci
15231e934351Sopenharmony_ci    /**
15241e934351Sopenharmony_ci     * Cancels listening for connection events of the LocalSocket connection.
15251e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
15261e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
15271e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15281e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15291e934351Sopenharmony_ci     * @since 11
15301e934351Sopenharmony_ci     */
15311e934351Sopenharmony_ci    /**
15321e934351Sopenharmony_ci     * Cancels listening for connection events of the LocalSocket connection.
15331e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
15341e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
15351e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15361e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15371e934351Sopenharmony_ci     * @crossplatform
15381e934351Sopenharmony_ci     * @since 12
15391e934351Sopenharmony_ci     */
15401e934351Sopenharmony_ci    off(type: 'connect', callback?: Callback<void>): void;
15411e934351Sopenharmony_ci
15421e934351Sopenharmony_ci    /**
15431e934351Sopenharmony_ci     * Listens for close events of the LocalSocket connection.
15441e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
15451e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
15461e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15471e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15481e934351Sopenharmony_ci     * @since 11
15491e934351Sopenharmony_ci     */
15501e934351Sopenharmony_ci    /**
15511e934351Sopenharmony_ci     * Listens for close events of the LocalSocket connection.
15521e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
15531e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
15541e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15551e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15561e934351Sopenharmony_ci     * @crossplatform
15571e934351Sopenharmony_ci     * @since 12
15581e934351Sopenharmony_ci     */
15591e934351Sopenharmony_ci    on(type: 'close', callback: Callback<void>): void;
15601e934351Sopenharmony_ci
15611e934351Sopenharmony_ci    /**
15621e934351Sopenharmony_ci     * Cancels listening for close events of the LocalSocket connection.
15631e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
15641e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
15651e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15661e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15671e934351Sopenharmony_ci     * @since 11
15681e934351Sopenharmony_ci     */
15691e934351Sopenharmony_ci    /**
15701e934351Sopenharmony_ci     * Cancels listening for close events of the LocalSocket connection.
15711e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
15721e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
15731e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15741e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15751e934351Sopenharmony_ci     * @crossplatform
15761e934351Sopenharmony_ci     * @since 12
15771e934351Sopenharmony_ci     */
15781e934351Sopenharmony_ci    off(type: 'close', callback?: Callback<void>): void;
15791e934351Sopenharmony_ci
15801e934351Sopenharmony_ci    /**
15811e934351Sopenharmony_ci     * Listens for error events of the LocalSocket connection.
15821e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
15831e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
15841e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15851e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15861e934351Sopenharmony_ci     * @since 11
15871e934351Sopenharmony_ci     */
15881e934351Sopenharmony_ci    /**
15891e934351Sopenharmony_ci     * Listens for error events of the LocalSocket connection.
15901e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
15911e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
15921e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
15931e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
15941e934351Sopenharmony_ci     * @crossplatform
15951e934351Sopenharmony_ci     * @since 12
15961e934351Sopenharmony_ci     */
15971e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
15981e934351Sopenharmony_ci
15991e934351Sopenharmony_ci    /**
16001e934351Sopenharmony_ci     * Cancels listening for error events of the LocalSocket connection.
16011e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
16021e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
16031e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
16041e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16051e934351Sopenharmony_ci     * @since 11
16061e934351Sopenharmony_ci     */
16071e934351Sopenharmony_ci    /**
16081e934351Sopenharmony_ci     * Cancels listening for error events of the LocalSocket connection.
16091e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
16101e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
16111e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
16121e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16131e934351Sopenharmony_ci     * @crossplatform
16141e934351Sopenharmony_ci     * @since 12
16151e934351Sopenharmony_ci     */
16161e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
16171e934351Sopenharmony_ci  }
16181e934351Sopenharmony_ci
16191e934351Sopenharmony_ci  /**
16201e934351Sopenharmony_ci   * Defines the connection of the LocalSocket client and server.
16211e934351Sopenharmony_ci   * @interface LocalSocketConnection
16221e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
16231e934351Sopenharmony_ci   * @since 11
16241e934351Sopenharmony_ci   */
16251e934351Sopenharmony_ci  /**
16261e934351Sopenharmony_ci   * Defines the connection of the LocalSocket client and server.
16271e934351Sopenharmony_ci   * @interface LocalSocketConnection
16281e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
16291e934351Sopenharmony_ci   * @crossplatform
16301e934351Sopenharmony_ci   * @since 12
16311e934351Sopenharmony_ci   */
16321e934351Sopenharmony_ci  export interface LocalSocketConnection {
16331e934351Sopenharmony_ci    /**
16341e934351Sopenharmony_ci     * The id of a client connects to the LocalSocketServer.
16351e934351Sopenharmony_ci     * @type {number}
16361e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16371e934351Sopenharmony_ci     * @since 11
16381e934351Sopenharmony_ci     */
16391e934351Sopenharmony_ci    /**
16401e934351Sopenharmony_ci     * The id of a client connects to the LocalSocketServer.
16411e934351Sopenharmony_ci     * @type {number}
16421e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16431e934351Sopenharmony_ci     * @crossplatform
16441e934351Sopenharmony_ci     * @since 12
16451e934351Sopenharmony_ci     */
16461e934351Sopenharmony_ci    clientId: number;
16471e934351Sopenharmony_ci
16481e934351Sopenharmony_ci    /**
16491e934351Sopenharmony_ci     * Sends data over a LocalSocketServer connection to client.
16501e934351Sopenharmony_ci     * @param { LocalSendOptions } options - Parameters for sending data {@link LocalSendOptions}.
16511e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
16521e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
16531e934351Sopenharmony_ci     * @throws { BusinessError } 2301011 - Operation would block.
16541e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16551e934351Sopenharmony_ci     * @since 11
16561e934351Sopenharmony_ci     */
16571e934351Sopenharmony_ci    /**
16581e934351Sopenharmony_ci     * Sends data over a LocalSocketServer connection to client.
16591e934351Sopenharmony_ci     * @param { LocalSendOptions } options - Parameters for sending data {@link LocalSendOptions}.
16601e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
16611e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
16621e934351Sopenharmony_ci     * @throws { BusinessError } 2301011 - Operation would block.
16631e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16641e934351Sopenharmony_ci     * @crossplatform
16651e934351Sopenharmony_ci     * @since 12
16661e934351Sopenharmony_ci     */
16671e934351Sopenharmony_ci    send(options: LocalSendOptions): Promise<void>;
16681e934351Sopenharmony_ci
16691e934351Sopenharmony_ci    /**
16701e934351Sopenharmony_ci     * Closes a LocalSocket client connection.
16711e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
16721e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
16731e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16741e934351Sopenharmony_ci     * @since 11
16751e934351Sopenharmony_ci     */
16761e934351Sopenharmony_ci    /**
16771e934351Sopenharmony_ci     * Closes a LocalSocket client connection.
16781e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
16791e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
16801e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16811e934351Sopenharmony_ci     * @crossplatform
16821e934351Sopenharmony_ci     * @since 12
16831e934351Sopenharmony_ci     */
16841e934351Sopenharmony_ci    close(): Promise<void>;
16851e934351Sopenharmony_ci
16861e934351Sopenharmony_ci    /**
16871e934351Sopenharmony_ci     * Obtains the local address of a LocalSocket client connection.
16881e934351Sopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
16891e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
16901e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
16911e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
16921e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
16931e934351Sopenharmony_ci     * @since 12
16941e934351Sopenharmony_ci     */
16951e934351Sopenharmony_ci    getLocalAddress(): Promise<string>;
16961e934351Sopenharmony_ci
16971e934351Sopenharmony_ci    /**
16981e934351Sopenharmony_ci     * Listens for message receiving events of the LocalSocketConnection.
16991e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
17001e934351Sopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of on.
17011e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17021e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17031e934351Sopenharmony_ci     * @since 11
17041e934351Sopenharmony_ci     */
17051e934351Sopenharmony_ci    /**
17061e934351Sopenharmony_ci     * Listens for message receiving events of the LocalSocketConnection.
17071e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
17081e934351Sopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of on.
17091e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17101e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17111e934351Sopenharmony_ci     * @crossplatform
17121e934351Sopenharmony_ci     * @since 12
17131e934351Sopenharmony_ci     */
17141e934351Sopenharmony_ci    on(type: 'message', callback: Callback<LocalSocketMessageInfo>): void;
17151e934351Sopenharmony_ci
17161e934351Sopenharmony_ci    /**
17171e934351Sopenharmony_ci     * Cancels listening for message receiving events of the LocalSocketConnection.
17181e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
17191e934351Sopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of off.
17201e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17211e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17221e934351Sopenharmony_ci     * @since 11
17231e934351Sopenharmony_ci     */
17241e934351Sopenharmony_ci    /**
17251e934351Sopenharmony_ci     * Cancels listening for message receiving events of the LocalSocketConnection.
17261e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
17271e934351Sopenharmony_ci     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of off.
17281e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17301e934351Sopenharmony_ci     * @crossplatform
17311e934351Sopenharmony_ci     * @since 12
17321e934351Sopenharmony_ci     */
17331e934351Sopenharmony_ci    off(type: 'message', callback?: Callback<LocalSocketMessageInfo>): void;
17341e934351Sopenharmony_ci
17351e934351Sopenharmony_ci    /**
17361e934351Sopenharmony_ci     * Listens for close events of the LocalSocketConnection.
17371e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
17381e934351Sopenharmony_ci     * @param { Callback<void> } callback - The callback of on.
17391e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17401e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17411e934351Sopenharmony_ci     * @since 11
17421e934351Sopenharmony_ci     */
17431e934351Sopenharmony_ci    /**
17441e934351Sopenharmony_ci     * Listens for close events of the LocalSocketConnection.
17451e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
17461e934351Sopenharmony_ci     * @param { Callback<void> } callback - The callback of on.
17471e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17481e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17491e934351Sopenharmony_ci     * @crossplatform
17501e934351Sopenharmony_ci     * @since 12
17511e934351Sopenharmony_ci     */
17521e934351Sopenharmony_ci    on(type: 'close', callback: Callback<void>): void;
17531e934351Sopenharmony_ci
17541e934351Sopenharmony_ci    /**
17551e934351Sopenharmony_ci     * Cancels listening for close events of the LocalSocketConnection.
17561e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
17571e934351Sopenharmony_ci     * @param { Callback<void> } callback - The callback of off.
17581e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17591e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17601e934351Sopenharmony_ci     * @since 11
17611e934351Sopenharmony_ci     */
17621e934351Sopenharmony_ci    /**
17631e934351Sopenharmony_ci     * Cancels listening for close events of the LocalSocketConnection.
17641e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
17651e934351Sopenharmony_ci     * @param { Callback<void> } callback - The callback of off.
17661e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17671e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17681e934351Sopenharmony_ci     * @crossplatform
17691e934351Sopenharmony_ci     * @since 12
17701e934351Sopenharmony_ci     */
17711e934351Sopenharmony_ci    off(type: 'close', callback?: Callback<void>): void;
17721e934351Sopenharmony_ci
17731e934351Sopenharmony_ci    /**
17741e934351Sopenharmony_ci     * Listens for error events of the LocalSocketConnection.
17751e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
17761e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
17771e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17791e934351Sopenharmony_ci     * @since 11
17801e934351Sopenharmony_ci     */
17811e934351Sopenharmony_ci    /**
17821e934351Sopenharmony_ci     * Listens for error events of the LocalSocketConnection.
17831e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
17841e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
17851e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17861e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17871e934351Sopenharmony_ci     * @crossplatform
17881e934351Sopenharmony_ci     * @since 12
17891e934351Sopenharmony_ci     */
17901e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
17911e934351Sopenharmony_ci
17921e934351Sopenharmony_ci    /**
17931e934351Sopenharmony_ci     * Cancels listening for error events of the LocalSocketConnection.
17941e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
17951e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
17961e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
17971e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
17981e934351Sopenharmony_ci     * @since 11
17991e934351Sopenharmony_ci     */
18001e934351Sopenharmony_ci    /**
18011e934351Sopenharmony_ci     * Cancels listening for error events of the LocalSocketConnection.
18021e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
18031e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
18041e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
18051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
18061e934351Sopenharmony_ci     * @crossplatform
18071e934351Sopenharmony_ci     * @since 12
18081e934351Sopenharmony_ci     */
18091e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
18101e934351Sopenharmony_ci  }
18111e934351Sopenharmony_ci
18121e934351Sopenharmony_ci  /**
18131e934351Sopenharmony_ci   * Defines a LocalSocket server connection.
18141e934351Sopenharmony_ci   * @interface LocalSocketServer
18151e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
18161e934351Sopenharmony_ci   * @since 11
18171e934351Sopenharmony_ci   */
18181e934351Sopenharmony_ci  /**
18191e934351Sopenharmony_ci   * Defines a LocalSocket server connection.
18201e934351Sopenharmony_ci   * @interface LocalSocketServer
18211e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
18221e934351Sopenharmony_ci   * @crossplatform
18231e934351Sopenharmony_ci   * @since 12
18241e934351Sopenharmony_ci   */
18251e934351Sopenharmony_ci  export interface LocalSocketServer {
18261e934351Sopenharmony_ci    /**
18271e934351Sopenharmony_ci     * Binds the Local address.
18281e934351Sopenharmony_ci     * <p>Listens for a LocalSocket connection to be made to this socket and accepts it. This interface uses multiple threads
18291e934351Sopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
18301e934351Sopenharmony_ci     * @param { LocalAddress } address - Network address information {@link LocalAddress}.
18311e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
18321e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
18331e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
18341e934351Sopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
18351e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
18361e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address already in use.
18371e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
18381e934351Sopenharmony_ci     * @since 11
18391e934351Sopenharmony_ci     */
18401e934351Sopenharmony_ci    /**
18411e934351Sopenharmony_ci     * Binds the Local address.
18421e934351Sopenharmony_ci     * <p>Listens for a LocalSocket connection to be made to this socket and accepts it. This interface uses multiple threads
18431e934351Sopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
18441e934351Sopenharmony_ci     * @param { LocalAddress } address - Network address information {@link LocalAddress}.
18451e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
18461e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
18471e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
18481e934351Sopenharmony_ci     * @throws { BusinessError } 2301013 - Insufficient permissions.
18491e934351Sopenharmony_ci     * @throws { BusinessError } 2301022 - Invalid argument.
18501e934351Sopenharmony_ci     * @throws { BusinessError } 2301098 - Address already in use.
18511e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
18521e934351Sopenharmony_ci     * @crossplatform
18531e934351Sopenharmony_ci     * @since 12
18541e934351Sopenharmony_ci     */
18551e934351Sopenharmony_ci    listen(address: LocalAddress): Promise<void>;
18561e934351Sopenharmony_ci
18571e934351Sopenharmony_ci    /**
18581e934351Sopenharmony_ci     * Obtains the status of the LocalSocketServer connection.
18591e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
18601e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
18611e934351Sopenharmony_ci     * @since 11
18621e934351Sopenharmony_ci     */
18631e934351Sopenharmony_ci    /**
18641e934351Sopenharmony_ci     * Obtains the status of the LocalSocketServer connection.
18651e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
18661e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
18671e934351Sopenharmony_ci     * @crossplatform
18681e934351Sopenharmony_ci     * @since 12
18691e934351Sopenharmony_ci     */
18701e934351Sopenharmony_ci    getState(): Promise<SocketStateBase>;
18711e934351Sopenharmony_ci
18721e934351Sopenharmony_ci    /**
18731e934351Sopenharmony_ci     * Sets other attributes of the LocalSocketServer connection.
18741e934351Sopenharmony_ci     * @param { ExtraOptionsBase } options - Parameters of the attributes {@link ExtraOptionsBase}.
18751e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
18761e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
18771e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
18781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
18791e934351Sopenharmony_ci     * @since 11
18801e934351Sopenharmony_ci     */
18811e934351Sopenharmony_ci    /**
18821e934351Sopenharmony_ci     * Sets other attributes of the LocalSocketServer connection.
18831e934351Sopenharmony_ci     * @param { ExtraOptionsBase } options - Parameters of the attributes {@link ExtraOptionsBase}.
18841e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
18851e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
18861e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
18871e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
18881e934351Sopenharmony_ci     * @crossplatform
18891e934351Sopenharmony_ci     * @since 12
18901e934351Sopenharmony_ci     */
18911e934351Sopenharmony_ci    setExtraOptions(options: ExtraOptionsBase): Promise<void>;
18921e934351Sopenharmony_ci
18931e934351Sopenharmony_ci    /**
18941e934351Sopenharmony_ci     * Gets other attributes of the LocalSocket connection.
18951e934351Sopenharmony_ci     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
18961e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
18971e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
18981e934351Sopenharmony_ci     * @since 11
18991e934351Sopenharmony_ci     */
19001e934351Sopenharmony_ci    /**
19011e934351Sopenharmony_ci     * Gets other attributes of the LocalSocket connection.
19021e934351Sopenharmony_ci     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
19031e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19041e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19051e934351Sopenharmony_ci     * @crossplatform
19061e934351Sopenharmony_ci     * @since 12
19071e934351Sopenharmony_ci     */
19081e934351Sopenharmony_ci    getExtraOptions(): Promise<ExtraOptionsBase>;
19091e934351Sopenharmony_ci
19101e934351Sopenharmony_ci    /**
19111e934351Sopenharmony_ci     * Obtains the local address of the LocalSocketServer connection.
19121e934351Sopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
19131e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
19141e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
19151e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
19161e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19171e934351Sopenharmony_ci     * @since 12
19181e934351Sopenharmony_ci     */
19191e934351Sopenharmony_ci    getLocalAddress(): Promise<string>;
19201e934351Sopenharmony_ci
19211e934351Sopenharmony_ci    /**
19221e934351Sopenharmony_ci     * Listens for connect events of the LocalSocketServer connection.
19231e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
19241e934351Sopenharmony_ci     * @param { Callback<LocalSocketConnection> } callback - The callback of on.
19251e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19261e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19271e934351Sopenharmony_ci     * @since 11
19281e934351Sopenharmony_ci     */
19291e934351Sopenharmony_ci    /**
19301e934351Sopenharmony_ci     * Listens for connect events of the LocalSocketServer connection.
19311e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
19321e934351Sopenharmony_ci     * @param { Callback<LocalSocketConnection> } callback - The callback of on.
19331e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19341e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19351e934351Sopenharmony_ci     * @crossplatform
19361e934351Sopenharmony_ci     * @since 12
19371e934351Sopenharmony_ci     */
19381e934351Sopenharmony_ci    on(type: 'connect', callback: Callback<LocalSocketConnection>): void;
19391e934351Sopenharmony_ci
19401e934351Sopenharmony_ci    /**
19411e934351Sopenharmony_ci     * Cancels listening for connect events of the LocalSocketServer connection.
19421e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
19431e934351Sopenharmony_ci     * @param { Callback<LocalSocketConnection> } callback - The callback of off.
19441e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19451e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19461e934351Sopenharmony_ci     * @since 11
19471e934351Sopenharmony_ci     */
19481e934351Sopenharmony_ci    /**
19491e934351Sopenharmony_ci     * Cancels listening for connect events of the LocalSocketServer connection.
19501e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
19511e934351Sopenharmony_ci     * @param { Callback<LocalSocketConnection> } callback - The callback of off.
19521e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19531e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19541e934351Sopenharmony_ci     * @crossplatform
19551e934351Sopenharmony_ci     * @since 12
19561e934351Sopenharmony_ci     */
19571e934351Sopenharmony_ci    off(type: 'connect', callback?: Callback<LocalSocketConnection>): void;
19581e934351Sopenharmony_ci
19591e934351Sopenharmony_ci    /**
19601e934351Sopenharmony_ci     * Listens for error events of the LocalSocketServer connection.
19611e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
19621e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
19631e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19641e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19651e934351Sopenharmony_ci     * @since 11
19661e934351Sopenharmony_ci     */
19671e934351Sopenharmony_ci    /**
19681e934351Sopenharmony_ci     * Listens for error events of the LocalSocketServer connection.
19691e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
19701e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
19711e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19721e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19731e934351Sopenharmony_ci     * @crossplatform
19741e934351Sopenharmony_ci     * @since 12
19751e934351Sopenharmony_ci     */
19761e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
19771e934351Sopenharmony_ci
19781e934351Sopenharmony_ci    /**
19791e934351Sopenharmony_ci     * Cancels listening for error events of the LocalSocketServer connection.
19801e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
19811e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
19821e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19831e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19841e934351Sopenharmony_ci     * @since 11
19851e934351Sopenharmony_ci     */
19861e934351Sopenharmony_ci    /**
19871e934351Sopenharmony_ci     * Cancels listening for error events of the LocalSocketServer connection.
19881e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
19891e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
19901e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
19911e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
19921e934351Sopenharmony_ci     * @crossplatform
19931e934351Sopenharmony_ci     * @since 12
19941e934351Sopenharmony_ci     */
19951e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
19961e934351Sopenharmony_ci  }
19971e934351Sopenharmony_ci
19981e934351Sopenharmony_ci  /**
19991e934351Sopenharmony_ci   * Defines TCPSocket connection parameters.
20001e934351Sopenharmony_ci   * @interface TCPConnectOptions
20011e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
20021e934351Sopenharmony_ci   * @since 7
20031e934351Sopenharmony_ci   */
20041e934351Sopenharmony_ci  /**
20051e934351Sopenharmony_ci   * Defines TCPSocket connection parameters.
20061e934351Sopenharmony_ci   * @interface TCPConnectOptions
20071e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
20081e934351Sopenharmony_ci   * @crossplatform
20091e934351Sopenharmony_ci   * @since 10
20101e934351Sopenharmony_ci   */
20111e934351Sopenharmony_ci  export interface TCPConnectOptions {
20121e934351Sopenharmony_ci    /**
20131e934351Sopenharmony_ci     * Bound IP address and port number.
20141e934351Sopenharmony_ci     * @type { NetAddress }
20151e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20161e934351Sopenharmony_ci     * @since 7
20171e934351Sopenharmony_ci     */
20181e934351Sopenharmony_ci    /**
20191e934351Sopenharmony_ci     * Bound IP address and port number.
20201e934351Sopenharmony_ci     * @type { NetAddress }
20211e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20221e934351Sopenharmony_ci     * @crossplatform
20231e934351Sopenharmony_ci     * @since 10
20241e934351Sopenharmony_ci     */
20251e934351Sopenharmony_ci    address: NetAddress;
20261e934351Sopenharmony_ci
20271e934351Sopenharmony_ci    /**
20281e934351Sopenharmony_ci     * Timeout duration of the TCPSocket connection, in milliseconds.
20291e934351Sopenharmony_ci     * @type { ?number }
20301e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20311e934351Sopenharmony_ci     * @since 7
20321e934351Sopenharmony_ci     */
20331e934351Sopenharmony_ci    /**
20341e934351Sopenharmony_ci     * Timeout duration of the TCPSocket connection, in milliseconds.
20351e934351Sopenharmony_ci     * @type { ?number }
20361e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20371e934351Sopenharmony_ci     * @crossplatform
20381e934351Sopenharmony_ci     * @since 10
20391e934351Sopenharmony_ci     */
20401e934351Sopenharmony_ci    timeout?: number;
20411e934351Sopenharmony_ci  }
20421e934351Sopenharmony_ci
20431e934351Sopenharmony_ci  /**
20441e934351Sopenharmony_ci   * Defines the parameters for sending data over the TCPSocket connection.
20451e934351Sopenharmony_ci   * @interface TCPSendOptions
20461e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
20471e934351Sopenharmony_ci   * @since 7
20481e934351Sopenharmony_ci   */
20491e934351Sopenharmony_ci  /**
20501e934351Sopenharmony_ci   * Defines the parameters for sending data over the TCPSocket connection.
20511e934351Sopenharmony_ci   * @interface TCPSendOptions
20521e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
20531e934351Sopenharmony_ci   * @crossplatform
20541e934351Sopenharmony_ci   * @since 10
20551e934351Sopenharmony_ci   */
20561e934351Sopenharmony_ci  export interface TCPSendOptions {
20571e934351Sopenharmony_ci    /**
20581e934351Sopenharmony_ci     * Data to send.
20591e934351Sopenharmony_ci     * @type { string | ArrayBuffer }
20601e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20611e934351Sopenharmony_ci     * @since 7
20621e934351Sopenharmony_ci     */
20631e934351Sopenharmony_ci    /**
20641e934351Sopenharmony_ci     * Data to send.
20651e934351Sopenharmony_ci     * @type { string | ArrayBuffer }
20661e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20671e934351Sopenharmony_ci     * @crossplatform
20681e934351Sopenharmony_ci     * @since 10
20691e934351Sopenharmony_ci     */
20701e934351Sopenharmony_ci    data: string | ArrayBuffer;
20711e934351Sopenharmony_ci
20721e934351Sopenharmony_ci    /**
20731e934351Sopenharmony_ci     * Character encoding format.
20741e934351Sopenharmony_ci     * @type { ?string }
20751e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20761e934351Sopenharmony_ci     * @since 7
20771e934351Sopenharmony_ci     */
20781e934351Sopenharmony_ci    /**
20791e934351Sopenharmony_ci     * Character encoding format.
20801e934351Sopenharmony_ci     * @type { ?string }
20811e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
20821e934351Sopenharmony_ci     * @crossplatform
20831e934351Sopenharmony_ci     * @since 10
20841e934351Sopenharmony_ci     */
20851e934351Sopenharmony_ci    encoding?: string;
20861e934351Sopenharmony_ci  }
20871e934351Sopenharmony_ci
20881e934351Sopenharmony_ci  /**
20891e934351Sopenharmony_ci   * Defines other properties of the TCPSocket connection.
20901e934351Sopenharmony_ci   * @interface TCPExtraOptions
20911e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
20921e934351Sopenharmony_ci   * @since 7
20931e934351Sopenharmony_ci   */
20941e934351Sopenharmony_ci  /**
20951e934351Sopenharmony_ci   * Defines other properties of the TCPSocket connection.
20961e934351Sopenharmony_ci   * @interface TCPExtraOptions
20971e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
20981e934351Sopenharmony_ci   * @crossplatform
20991e934351Sopenharmony_ci   * @since 10
21001e934351Sopenharmony_ci   */
21011e934351Sopenharmony_ci  export interface TCPExtraOptions extends ExtraOptionsBase {
21021e934351Sopenharmony_ci    /**
21031e934351Sopenharmony_ci     * Whether to keep the connection alive. The default value is false.
21041e934351Sopenharmony_ci     * @type { ?boolean }
21051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21061e934351Sopenharmony_ci     * @since 7
21071e934351Sopenharmony_ci     */
21081e934351Sopenharmony_ci    /**
21091e934351Sopenharmony_ci     * Whether to keep the connection alive. The default value is false.
21101e934351Sopenharmony_ci     * @type { ?boolean }
21111e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21121e934351Sopenharmony_ci     * @crossplatform
21131e934351Sopenharmony_ci     * @since 10
21141e934351Sopenharmony_ci     */
21151e934351Sopenharmony_ci    keepAlive?: boolean;
21161e934351Sopenharmony_ci
21171e934351Sopenharmony_ci    /**
21181e934351Sopenharmony_ci     * Whether to enable OOBInline. The default value is false.
21191e934351Sopenharmony_ci     * @type { ?boolean }
21201e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21211e934351Sopenharmony_ci     * @since 7
21221e934351Sopenharmony_ci     */
21231e934351Sopenharmony_ci    /**
21241e934351Sopenharmony_ci     * Whether to enable OOBInline. The default value is false.
21251e934351Sopenharmony_ci     * @type { ?boolean }
21261e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21271e934351Sopenharmony_ci     * @crossplatform
21281e934351Sopenharmony_ci     * @since 10
21291e934351Sopenharmony_ci     */
21301e934351Sopenharmony_ci    OOBInline?: boolean;
21311e934351Sopenharmony_ci
21321e934351Sopenharmony_ci    /**
21331e934351Sopenharmony_ci     * Whether to enable no-delay on the TCPSocket connection. The default value is false.
21341e934351Sopenharmony_ci     * @type { ?boolean }
21351e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21361e934351Sopenharmony_ci     * @since 7
21371e934351Sopenharmony_ci     */
21381e934351Sopenharmony_ci    /**
21391e934351Sopenharmony_ci     * Whether to enable no-delay on the TCPSocket connection. The default value is false.
21401e934351Sopenharmony_ci     * @type { ?boolean }
21411e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21421e934351Sopenharmony_ci     * @crossplatform
21431e934351Sopenharmony_ci     * @since 10
21441e934351Sopenharmony_ci     */
21451e934351Sopenharmony_ci    TCPNoDelay?: boolean;
21461e934351Sopenharmony_ci
21471e934351Sopenharmony_ci    /**
21481e934351Sopenharmony_ci     * Socket linger.
21491e934351Sopenharmony_ci     * @type { ?object }
21501e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21511e934351Sopenharmony_ci     * @crossplatform
21521e934351Sopenharmony_ci     * @since 7
21531e934351Sopenharmony_ci     */
21541e934351Sopenharmony_ci    /**
21551e934351Sopenharmony_ci     * Socket linger.
21561e934351Sopenharmony_ci     * @type { ?object }
21571e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21581e934351Sopenharmony_ci     * @crossplatform
21591e934351Sopenharmony_ci     * @since 10
21601e934351Sopenharmony_ci     */
21611e934351Sopenharmony_ci    socketLinger?: { on: boolean, linger: number };
21621e934351Sopenharmony_ci  }
21631e934351Sopenharmony_ci
21641e934351Sopenharmony_ci  /**
21651e934351Sopenharmony_ci   * Defines a TCPSocket connection.
21661e934351Sopenharmony_ci   * @interface TCPSocket
21671e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
21681e934351Sopenharmony_ci   * @since 7
21691e934351Sopenharmony_ci   */
21701e934351Sopenharmony_ci  /**
21711e934351Sopenharmony_ci   * Defines a TCPSocket connection.
21721e934351Sopenharmony_ci   * @interface TCPSocket
21731e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
21741e934351Sopenharmony_ci   * @crossplatform
21751e934351Sopenharmony_ci   * @since 10
21761e934351Sopenharmony_ci   */
21771e934351Sopenharmony_ci  export interface TCPSocket {
21781e934351Sopenharmony_ci    /**
21791e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
21801e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
21811e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
21821e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - Return the callback of bind.
21831e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
21841e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
21851e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21861e934351Sopenharmony_ci     * @since 7
21871e934351Sopenharmony_ci     */
21881e934351Sopenharmony_ci    /**
21891e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
21901e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
21911e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
21921e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
21931e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
21941e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
21951e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
21961e934351Sopenharmony_ci     * @crossplatform
21971e934351Sopenharmony_ci     * @since 10
21981e934351Sopenharmony_ci     */
21991e934351Sopenharmony_ci    bind(address: NetAddress, callback: AsyncCallback<void>): void;
22001e934351Sopenharmony_ci
22011e934351Sopenharmony_ci    /**
22021e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
22031e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22041e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
22051e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
22061e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22071e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
22081e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
22091e934351Sopenharmony_ci     * @since 7
22101e934351Sopenharmony_ci     */
22111e934351Sopenharmony_ci    /**
22121e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
22131e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22141e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
22151e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
22161e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22171e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
22181e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
22191e934351Sopenharmony_ci     * @crossplatform
22201e934351Sopenharmony_ci     * @since 10
22211e934351Sopenharmony_ci     */
22221e934351Sopenharmony_ci    bind(address: NetAddress): Promise<void>;
22231e934351Sopenharmony_ci
22241e934351Sopenharmony_ci    /**
22251e934351Sopenharmony_ci     * Sets up a connection to the specified IP address and port number.
22261e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22271e934351Sopenharmony_ci     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
22281e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of connect.
22291e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22301e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
22311e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
22321e934351Sopenharmony_ci     * @since 7
22331e934351Sopenharmony_ci     */
22341e934351Sopenharmony_ci    /**
22351e934351Sopenharmony_ci     * Sets up a connection to the specified IP address and port number.
22361e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22371e934351Sopenharmony_ci     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
22381e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of connect.
22391e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22401e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
22411e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
22421e934351Sopenharmony_ci     * @crossplatform
22431e934351Sopenharmony_ci     * @since 10
22441e934351Sopenharmony_ci     */
22451e934351Sopenharmony_ci    connect(options: TCPConnectOptions, callback: AsyncCallback<void>): void;
22461e934351Sopenharmony_ci
22471e934351Sopenharmony_ci    /**
22481e934351Sopenharmony_ci     * Sets up a connection to the specified IP address and port number.
22491e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22501e934351Sopenharmony_ci     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
22511e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
22521e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22531e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
22541e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
22551e934351Sopenharmony_ci     * @since 7
22561e934351Sopenharmony_ci     */
22571e934351Sopenharmony_ci    /**
22581e934351Sopenharmony_ci     * Sets up a connection to the specified IP address and port number.
22591e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22601e934351Sopenharmony_ci     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
22611e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
22621e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22631e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
22641e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
22651e934351Sopenharmony_ci     * @crossplatform
22661e934351Sopenharmony_ci     * @since 10
22671e934351Sopenharmony_ci     */
22681e934351Sopenharmony_ci    connect(options: TCPConnectOptions): Promise<void>;
22691e934351Sopenharmony_ci
22701e934351Sopenharmony_ci    /**
22711e934351Sopenharmony_ci     * Sends data over a TCPSocket connection.
22721e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22731e934351Sopenharmony_ci     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
22741e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
22751e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22761e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
22771e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
22781e934351Sopenharmony_ci     * @since 7
22791e934351Sopenharmony_ci     */
22801e934351Sopenharmony_ci    /**
22811e934351Sopenharmony_ci     * Sends data over a TCPSocket connection.
22821e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22831e934351Sopenharmony_ci     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
22841e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
22851e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22861e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
22871e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
22881e934351Sopenharmony_ci     * @crossplatform
22891e934351Sopenharmony_ci     * @since 10
22901e934351Sopenharmony_ci     */
22911e934351Sopenharmony_ci    send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
22921e934351Sopenharmony_ci
22931e934351Sopenharmony_ci    /**
22941e934351Sopenharmony_ci     * Sends data over a TCPSocket connection.
22951e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
22961e934351Sopenharmony_ci     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
22971e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
22981e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
22991e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23001e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23011e934351Sopenharmony_ci     * @since 7
23021e934351Sopenharmony_ci     */
23031e934351Sopenharmony_ci    /**
23041e934351Sopenharmony_ci     * Sends data over a TCPSocket connection.
23051e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23061e934351Sopenharmony_ci     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
23071e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
23081e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
23091e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23101e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23111e934351Sopenharmony_ci     * @crossplatform
23121e934351Sopenharmony_ci     * @since 10
23131e934351Sopenharmony_ci     */
23141e934351Sopenharmony_ci    send(options: TCPSendOptions): Promise<void>;
23151e934351Sopenharmony_ci
23161e934351Sopenharmony_ci    /**
23171e934351Sopenharmony_ci     * Closes a TCPSocket connection.
23181e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23191e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
23201e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23211e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23221e934351Sopenharmony_ci     * @since 7
23231e934351Sopenharmony_ci     */
23241e934351Sopenharmony_ci    /**
23251e934351Sopenharmony_ci     * Closes a TCPSocket connection.
23261e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23271e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
23281e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23301e934351Sopenharmony_ci     * @crossplatform
23311e934351Sopenharmony_ci     * @since 10
23321e934351Sopenharmony_ci     */
23331e934351Sopenharmony_ci    close(callback: AsyncCallback<void>): void;
23341e934351Sopenharmony_ci
23351e934351Sopenharmony_ci    /**
23361e934351Sopenharmony_ci     * Closes a TCPSocket connection.
23371e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23381e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
23391e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23401e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23411e934351Sopenharmony_ci     * @since 7
23421e934351Sopenharmony_ci     */
23431e934351Sopenharmony_ci    /**
23441e934351Sopenharmony_ci     * Closes a TCPSocket connection.
23451e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23461e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
23471e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23481e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23491e934351Sopenharmony_ci     * @crossplatform
23501e934351Sopenharmony_ci     * @since 10
23511e934351Sopenharmony_ci     */
23521e934351Sopenharmony_ci    close(): Promise<void>;
23531e934351Sopenharmony_ci
23541e934351Sopenharmony_ci    /**
23551e934351Sopenharmony_ci     * Obtains the peer address of a TCPSocket connection.
23561e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23571e934351Sopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress. {@link NetAddress}
23581e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23591e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23601e934351Sopenharmony_ci     * @since 7
23611e934351Sopenharmony_ci     */
23621e934351Sopenharmony_ci    /**
23631e934351Sopenharmony_ci     * Obtains the peer address of a TCPSocket connection.
23641e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23651e934351Sopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress. {@link NetAddress}
23661e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23671e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23681e934351Sopenharmony_ci     * @crossplatform
23691e934351Sopenharmony_ci     * @since 10
23701e934351Sopenharmony_ci     */
23711e934351Sopenharmony_ci    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
23721e934351Sopenharmony_ci
23731e934351Sopenharmony_ci    /**
23741e934351Sopenharmony_ci     * Obtains the peer address of a TCPSocket connection.
23751e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23761e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
23771e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23791e934351Sopenharmony_ci     * @since 7
23801e934351Sopenharmony_ci     */
23811e934351Sopenharmony_ci    /**
23821e934351Sopenharmony_ci     * Obtains the peer address of a TCPSocket connection.
23831e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23841e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
23851e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23861e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23871e934351Sopenharmony_ci     * @crossplatform
23881e934351Sopenharmony_ci     * @since 10
23891e934351Sopenharmony_ci     */
23901e934351Sopenharmony_ci    getRemoteAddress(): Promise<NetAddress>;
23911e934351Sopenharmony_ci
23921e934351Sopenharmony_ci    /**
23931e934351Sopenharmony_ci     * Obtains the status of the TCPSocket connection.
23941e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
23951e934351Sopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}
23961e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
23971e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
23981e934351Sopenharmony_ci     * @since 7
23991e934351Sopenharmony_ci     */
24001e934351Sopenharmony_ci    /**
24011e934351Sopenharmony_ci     * Obtains the status of the TCPSocket connection.
24021e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
24031e934351Sopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}
24041e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
24051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24061e934351Sopenharmony_ci     * @crossplatform
24071e934351Sopenharmony_ci     * @since 10
24081e934351Sopenharmony_ci     */
24091e934351Sopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
24101e934351Sopenharmony_ci
24111e934351Sopenharmony_ci    /**
24121e934351Sopenharmony_ci     * Obtains the status of the TCPSocket connection.
24131e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
24141e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
24151e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
24161e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24171e934351Sopenharmony_ci     * @since 7
24181e934351Sopenharmony_ci     */
24191e934351Sopenharmony_ci    /**
24201e934351Sopenharmony_ci     * Obtains the status of the TCPSocket connection.
24211e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
24221e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
24231e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
24241e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24251e934351Sopenharmony_ci     * @crossplatform
24261e934351Sopenharmony_ci     * @since 10
24271e934351Sopenharmony_ci     */
24281e934351Sopenharmony_ci    getState(): Promise<SocketStateBase>;
24291e934351Sopenharmony_ci
24301e934351Sopenharmony_ci    /**
24311e934351Sopenharmony_ci     * Obtains the file descriptor of the TCPSocket connection.
24321e934351Sopenharmony_ci     * @param { AsyncCallback<number> } callback - The callback returns the file descriptor of the TCPSocket connection.
24331e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24341e934351Sopenharmony_ci     * @since 10
24351e934351Sopenharmony_ci     */
24361e934351Sopenharmony_ci    getSocketFd(callback: AsyncCallback<number>): void;
24371e934351Sopenharmony_ci
24381e934351Sopenharmony_ci    /**
24391e934351Sopenharmony_ci     * Obtains the file descriptor of the TCPSocket connection.
24401e934351Sopenharmony_ci     * @returns { Promise<number> } The promise returns the file descriptor of the TCPSocket connection.
24411e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24421e934351Sopenharmony_ci     * @since 10
24431e934351Sopenharmony_ci     */
24441e934351Sopenharmony_ci    getSocketFd(): Promise<number>;
24451e934351Sopenharmony_ci
24461e934351Sopenharmony_ci    /**
24471e934351Sopenharmony_ci     * Sets other attributes of the TCPSocket connection.
24481e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
24491e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
24501e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
24511e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
24521e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
24531e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24541e934351Sopenharmony_ci     * @since 7
24551e934351Sopenharmony_ci     */
24561e934351Sopenharmony_ci    /**
24571e934351Sopenharmony_ci     * Sets other attributes of the TCPSocket connection.
24581e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
24591e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
24601e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
24611e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
24621e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
24631e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24641e934351Sopenharmony_ci     * @crossplatform
24651e934351Sopenharmony_ci     * @since 10
24661e934351Sopenharmony_ci     */
24671e934351Sopenharmony_ci    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
24681e934351Sopenharmony_ci
24691e934351Sopenharmony_ci    /**
24701e934351Sopenharmony_ci     * Sets other attributes of the TCPSocket connection.
24711e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
24721e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
24731e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
24741e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
24751e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
24761e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24771e934351Sopenharmony_ci     * @since 7
24781e934351Sopenharmony_ci     */
24791e934351Sopenharmony_ci    /**
24801e934351Sopenharmony_ci     * Sets other attributes of the TCPSocket connection.
24811e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
24821e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
24831e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
24841e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
24851e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
24861e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24871e934351Sopenharmony_ci     * @crossplatform
24881e934351Sopenharmony_ci     * @since 10
24891e934351Sopenharmony_ci     */
24901e934351Sopenharmony_ci    setExtraOptions(options: TCPExtraOptions): Promise<void>;
24911e934351Sopenharmony_ci
24921e934351Sopenharmony_ci    /**
24931e934351Sopenharmony_ci     * Obtains the local address of a TCPSocket connection.
24941e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
24951e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
24961e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
24971e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
24981e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
24991e934351Sopenharmony_ci     * @since 12
25001e934351Sopenharmony_ci     */
25011e934351Sopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
25021e934351Sopenharmony_ci
25031e934351Sopenharmony_ci    /**
25041e934351Sopenharmony_ci     * Listens for message receiving events of the TCPSocket connection.
25051e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
25061e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
25071e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25081e934351Sopenharmony_ci     * @since 7
25091e934351Sopenharmony_ci     */
25101e934351Sopenharmony_ci    /**
25111e934351Sopenharmony_ci     * Listens for message receiving events of the TCPSocket connection.
25121e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
25131e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
25141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25151e934351Sopenharmony_ci     * @crossplatform
25161e934351Sopenharmony_ci     * @since 10
25171e934351Sopenharmony_ci     */
25181e934351Sopenharmony_ci    /**
25191e934351Sopenharmony_ci     * Listens for message receiving events of the TCPSocket connection.
25201e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
25211e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
25221e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25231e934351Sopenharmony_ci     * @crossplatform
25241e934351Sopenharmony_ci     * @since 11
25251e934351Sopenharmony_ci     */
25261e934351Sopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
25271e934351Sopenharmony_ci
25281e934351Sopenharmony_ci    /**
25291e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TCPSocket connection.
25301e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
25311e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
25321e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25331e934351Sopenharmony_ci     * @since 7
25341e934351Sopenharmony_ci     */
25351e934351Sopenharmony_ci    /**
25361e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TCPSocket connection.
25371e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
25381e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
25391e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25401e934351Sopenharmony_ci     * @crossplatform
25411e934351Sopenharmony_ci     * @since 10
25421e934351Sopenharmony_ci     */
25431e934351Sopenharmony_ci    /**
25441e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TCPSocket connection.
25451e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
25461e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
25471e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25481e934351Sopenharmony_ci     * @crossplatform
25491e934351Sopenharmony_ci     * @since 11
25501e934351Sopenharmony_ci     */
25511e934351Sopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
25521e934351Sopenharmony_ci
25531e934351Sopenharmony_ci
25541e934351Sopenharmony_ci    /**
25551e934351Sopenharmony_ci     * Listens for connection or close events of the TCPSocket connection.
25561e934351Sopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
25571e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
25581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25591e934351Sopenharmony_ci     * @since 7
25601e934351Sopenharmony_ci     */
25611e934351Sopenharmony_ci    /**
25621e934351Sopenharmony_ci     * Listens for connection or close events of the TCPSocket connection.
25631e934351Sopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
25641e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
25651e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25661e934351Sopenharmony_ci     * @crossplatform
25671e934351Sopenharmony_ci     * @since 10
25681e934351Sopenharmony_ci     */
25691e934351Sopenharmony_ci    on(type: 'connect' | 'close', callback: Callback<void>): void;
25701e934351Sopenharmony_ci
25711e934351Sopenharmony_ci    /**
25721e934351Sopenharmony_ci     * Cancels listening for connection or close events of the TCPSocket connection.
25731e934351Sopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
25741e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
25751e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25761e934351Sopenharmony_ci     * @since 7
25771e934351Sopenharmony_ci     */
25781e934351Sopenharmony_ci    /**
25791e934351Sopenharmony_ci     * Cancels listening for connection or close events of the TCPSocket connection.
25801e934351Sopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
25811e934351Sopenharmony_ci     * @param { Callback<void> } callback - the callback used to return the result.
25821e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25831e934351Sopenharmony_ci     * @crossplatform
25841e934351Sopenharmony_ci     * @since 10
25851e934351Sopenharmony_ci     */
25861e934351Sopenharmony_ci    off(type: 'connect' | 'close', callback?: Callback<void>): void;
25871e934351Sopenharmony_ci
25881e934351Sopenharmony_ci    /**
25891e934351Sopenharmony_ci     * Listens for error events of the TCPSocket connection.
25901e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
25911e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
25921e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
25931e934351Sopenharmony_ci     * @since 7
25941e934351Sopenharmony_ci     */
25951e934351Sopenharmony_ci    /**
25961e934351Sopenharmony_ci     * Listens for error events of the TCPSocket connection.
25971e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
25981e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
25991e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26001e934351Sopenharmony_ci     * @crossplatform
26011e934351Sopenharmony_ci     * @since 10
26021e934351Sopenharmony_ci     */
26031e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
26041e934351Sopenharmony_ci
26051e934351Sopenharmony_ci    /**
26061e934351Sopenharmony_ci     * Cancels listening for error events of the TCPSocket connection.
26071e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
26081e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
26091e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26101e934351Sopenharmony_ci     * @since 7
26111e934351Sopenharmony_ci     */
26121e934351Sopenharmony_ci    /**
26131e934351Sopenharmony_ci     * Cancels listening for error events of the TCPSocket connection.
26141e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
26151e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
26161e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26171e934351Sopenharmony_ci     * @crossplatform
26181e934351Sopenharmony_ci     * @since 10
26191e934351Sopenharmony_ci     */
26201e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
26211e934351Sopenharmony_ci  }
26221e934351Sopenharmony_ci
26231e934351Sopenharmony_ci  /**
26241e934351Sopenharmony_ci   * Defines a TLSSocket connection.
26251e934351Sopenharmony_ci   * @interface TLSSocket
26261e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
26271e934351Sopenharmony_ci   * @since 9
26281e934351Sopenharmony_ci   */
26291e934351Sopenharmony_ci  /**
26301e934351Sopenharmony_ci   * Defines a TLSSocket connection.
26311e934351Sopenharmony_ci   * @interface TLSSocket
26321e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
26331e934351Sopenharmony_ci   * @crossplatform
26341e934351Sopenharmony_ci   * @since 10
26351e934351Sopenharmony_ci   */
26361e934351Sopenharmony_ci  export interface TLSSocket {
26371e934351Sopenharmony_ci    /**
26381e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
26391e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
26401e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
26411e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
26421e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
26431e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
26441e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
26451e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
26461e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26471e934351Sopenharmony_ci     * @since 9
26481e934351Sopenharmony_ci     */
26491e934351Sopenharmony_ci    /**
26501e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
26511e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
26521e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
26531e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of bind.
26541e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
26551e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
26561e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
26571e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
26581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26591e934351Sopenharmony_ci     * @crossplatform
26601e934351Sopenharmony_ci     * @since 10
26611e934351Sopenharmony_ci     */
26621e934351Sopenharmony_ci    bind(address: NetAddress, callback: AsyncCallback<void>): void;
26631e934351Sopenharmony_ci
26641e934351Sopenharmony_ci    /**
26651e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
26661e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
26671e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
26681e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
26691e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
26701e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
26711e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
26721e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
26731e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26741e934351Sopenharmony_ci     * @since 9
26751e934351Sopenharmony_ci     */
26761e934351Sopenharmony_ci    /**
26771e934351Sopenharmony_ci     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
26781e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
26791e934351Sopenharmony_ci     * @param { NetAddress } address - Destination address. {@link NetAddress}
26801e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
26811e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
26821e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
26831e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
26841e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
26851e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26861e934351Sopenharmony_ci     * @crossplatform
26871e934351Sopenharmony_ci     * @since 10
26881e934351Sopenharmony_ci     */
26891e934351Sopenharmony_ci    bind(address: NetAddress): Promise<void>;
26901e934351Sopenharmony_ci
26911e934351Sopenharmony_ci    /**
26921e934351Sopenharmony_ci     * Obtains the peer address of a TLSSocket connection.
26931e934351Sopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress.
26941e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
26951e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
26961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
26971e934351Sopenharmony_ci     * @since 9
26981e934351Sopenharmony_ci     */
26991e934351Sopenharmony_ci    /**
27001e934351Sopenharmony_ci     * Obtains the peer address of a TLSSocket connection.
27011e934351Sopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress.
27021e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27031e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27041e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27051e934351Sopenharmony_ci     * @crossplatform
27061e934351Sopenharmony_ci     * @since 10
27071e934351Sopenharmony_ci     */
27081e934351Sopenharmony_ci    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
27091e934351Sopenharmony_ci
27101e934351Sopenharmony_ci    /**
27111e934351Sopenharmony_ci     * Obtains the peer address of a TLSSocket connection.
27121e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
27131e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27141e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27151e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27161e934351Sopenharmony_ci     * @since 9
27171e934351Sopenharmony_ci     */
27181e934351Sopenharmony_ci    /**
27191e934351Sopenharmony_ci     * Obtains the peer address of a TLSSocket connection.
27201e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
27211e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27221e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27231e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27241e934351Sopenharmony_ci     * @crossplatform
27251e934351Sopenharmony_ci     * @since 10
27261e934351Sopenharmony_ci     */
27271e934351Sopenharmony_ci    getRemoteAddress(): Promise<NetAddress>;
27281e934351Sopenharmony_ci
27291e934351Sopenharmony_ci    /**
27301e934351Sopenharmony_ci     * Obtains the status of the TLSSocket connection.
27311e934351Sopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState.
27321e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27331e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27341e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27351e934351Sopenharmony_ci     * @since 9
27361e934351Sopenharmony_ci     */
27371e934351Sopenharmony_ci    /**
27381e934351Sopenharmony_ci     * Obtains the status of the TLSSocket connection.
27391e934351Sopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState.
27401e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27411e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27421e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27431e934351Sopenharmony_ci     * @crossplatform
27441e934351Sopenharmony_ci     * @since 10
27451e934351Sopenharmony_ci     */
27461e934351Sopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
27471e934351Sopenharmony_ci
27481e934351Sopenharmony_ci    /**
27491e934351Sopenharmony_ci     * Obtains the status of the TLSSocket connection.
27501e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
27511e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27521e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27531e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27541e934351Sopenharmony_ci     * @since 9
27551e934351Sopenharmony_ci     */
27561e934351Sopenharmony_ci    /**
27571e934351Sopenharmony_ci     * Obtains the status of the TLSSocket connection.
27581e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
27591e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27601e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27611e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27621e934351Sopenharmony_ci     * @crossplatform
27631e934351Sopenharmony_ci     * @since 10
27641e934351Sopenharmony_ci     */
27651e934351Sopenharmony_ci    getState(): Promise<SocketStateBase>;
27661e934351Sopenharmony_ci
27671e934351Sopenharmony_ci    /**
27681e934351Sopenharmony_ci     * Sets other attributes of the TLSSocket connection.
27691e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
27701e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
27711e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
27721e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27731e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27741e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27751e934351Sopenharmony_ci     * @since 9
27761e934351Sopenharmony_ci     */
27771e934351Sopenharmony_ci    /**
27781e934351Sopenharmony_ci     * Sets other attributes of the TLSSocket connection.
27791e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
27801e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
27811e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
27821e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27831e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27841e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27851e934351Sopenharmony_ci     * @crossplatform
27861e934351Sopenharmony_ci     * @since 10
27871e934351Sopenharmony_ci     */
27881e934351Sopenharmony_ci    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
27891e934351Sopenharmony_ci
27901e934351Sopenharmony_ci    /**
27911e934351Sopenharmony_ci     * Sets other attributes of the TLSSocket connection.
27921e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
27931e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
27941e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
27951e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
27961e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
27971e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
27981e934351Sopenharmony_ci     * @since 9
27991e934351Sopenharmony_ci     */
28001e934351Sopenharmony_ci    /**
28011e934351Sopenharmony_ci     * Sets other attributes of the TLSSocket connection.
28021e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
28031e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
28041e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28051e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
28061e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
28071e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28081e934351Sopenharmony_ci     * @crossplatform
28091e934351Sopenharmony_ci     * @since 10
28101e934351Sopenharmony_ci     */
28111e934351Sopenharmony_ci    setExtraOptions(options: TCPExtraOptions): Promise<void>;
28121e934351Sopenharmony_ci
28131e934351Sopenharmony_ci    /**
28141e934351Sopenharmony_ci     * Obtains the local address of a TLSSocket connection.
28151e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
28161e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
28171e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
28181e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
28191e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28201e934351Sopenharmony_ci     * @since 12
28211e934351Sopenharmony_ci     */
28221e934351Sopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
28231e934351Sopenharmony_ci
28241e934351Sopenharmony_ci    /**
28251e934351Sopenharmony_ci     * Listens for message receiving events of the TLSSocket connection.
28261e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
28271e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
28281e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28301e934351Sopenharmony_ci     * @since 9
28311e934351Sopenharmony_ci     */
28321e934351Sopenharmony_ci    /**
28331e934351Sopenharmony_ci     * Listens for message receiving events of the TLSSocket connection.
28341e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
28351e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
28361e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28371e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28381e934351Sopenharmony_ci     * @crossplatform
28391e934351Sopenharmony_ci     * @since 10
28401e934351Sopenharmony_ci     */
28411e934351Sopenharmony_ci    /**
28421e934351Sopenharmony_ci     * Listens for message receiving events of the TLSSocket connection.
28431e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
28441e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
28451e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28461e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28471e934351Sopenharmony_ci     * @crossplatform
28481e934351Sopenharmony_ci     * @since 11
28491e934351Sopenharmony_ci     */
28501e934351Sopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
28511e934351Sopenharmony_ci
28521e934351Sopenharmony_ci    /**
28531e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TLSSocket connection.
28541e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
28551e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
28561e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28571e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28581e934351Sopenharmony_ci     * @since 9
28591e934351Sopenharmony_ci     */
28601e934351Sopenharmony_ci    /**
28611e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TLSSocket connection.
28621e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
28631e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
28641e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28651e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28661e934351Sopenharmony_ci     * @crossplatform
28671e934351Sopenharmony_ci     * @since 10
28681e934351Sopenharmony_ci     */
28691e934351Sopenharmony_ci    /**
28701e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TLSSocket connection.
28711e934351Sopenharmony_ci     * @param { 'message' } type Indicates Event name.
28721e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
28731e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28741e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28751e934351Sopenharmony_ci     * @crossplatform
28761e934351Sopenharmony_ci     * @since 11
28771e934351Sopenharmony_ci     */
28781e934351Sopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
28791e934351Sopenharmony_ci
28801e934351Sopenharmony_ci    /**
28811e934351Sopenharmony_ci     * Listens for connection or close events of the TLSSocket connection.
28821e934351Sopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
28831e934351Sopenharmony_ci     * @param {Callback<void> } callback - the callback used to return the result.
28841e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28851e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28861e934351Sopenharmony_ci     * @since 9
28871e934351Sopenharmony_ci     */
28881e934351Sopenharmony_ci    /**
28891e934351Sopenharmony_ci     * Listens for connection or close events of the TLSSocket connection.
28901e934351Sopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
28911e934351Sopenharmony_ci     * @param {Callback<void> } callback - the callback used to return the result.
28921e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
28931e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
28941e934351Sopenharmony_ci     * @crossplatform
28951e934351Sopenharmony_ci     * @since 10
28961e934351Sopenharmony_ci     */
28971e934351Sopenharmony_ci    on(type: 'connect' | 'close', callback: Callback<void>): void;
28981e934351Sopenharmony_ci
28991e934351Sopenharmony_ci    /**
29001e934351Sopenharmony_ci     * Cancels listening for connection or close events of the TLSSocket connection.
29011e934351Sopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
29021e934351Sopenharmony_ci     * @param {Callback<void> } callback - the callback used to return the result.
29031e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
29041e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29051e934351Sopenharmony_ci     * @since 9
29061e934351Sopenharmony_ci     */
29071e934351Sopenharmony_ci    /**
29081e934351Sopenharmony_ci     * Cancels listening for connection or close events of the TLSSocket connection.
29091e934351Sopenharmony_ci     * @param { 'connect' | 'close' } type - Indicates Event name.
29101e934351Sopenharmony_ci     * @param {Callback<void> } callback - the callback used to return the result.
29111e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
29121e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29131e934351Sopenharmony_ci     * @crossplatform
29141e934351Sopenharmony_ci     * @since 10
29151e934351Sopenharmony_ci     */
29161e934351Sopenharmony_ci    off(type: 'connect' | 'close', callback?: Callback<void>): void;
29171e934351Sopenharmony_ci
29181e934351Sopenharmony_ci    /**
29191e934351Sopenharmony_ci     * Listens for error events of the TLSSocket connection.
29201e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
29211e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
29221e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
29231e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29241e934351Sopenharmony_ci     * @since 9
29251e934351Sopenharmony_ci     */
29261e934351Sopenharmony_ci    /**
29271e934351Sopenharmony_ci     * Listens for error events of the TLSSocket connection.
29281e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
29291e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
29301e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
29311e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29321e934351Sopenharmony_ci     * @crossplatform
29331e934351Sopenharmony_ci     * @since 10
29341e934351Sopenharmony_ci     */
29351e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
29361e934351Sopenharmony_ci
29371e934351Sopenharmony_ci    /**
29381e934351Sopenharmony_ci     * Cancels listening for error events of the TLSSocket connection.
29391e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
29401e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
29411e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
29421e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29431e934351Sopenharmony_ci     * @since 9
29441e934351Sopenharmony_ci     */
29451e934351Sopenharmony_ci    /**
29461e934351Sopenharmony_ci     * Cancels listening for error events of the TLSSocket connection.
29471e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
29481e934351Sopenharmony_ci     * @param { ErrorCallback } callback - the callback used to return the result.
29491e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
29501e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29511e934351Sopenharmony_ci     * @crossplatform
29521e934351Sopenharmony_ci     * @since 10
29531e934351Sopenharmony_ci     */
29541e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
29551e934351Sopenharmony_ci
29561e934351Sopenharmony_ci    /**
29571e934351Sopenharmony_ci     * Returns an object representing a local certificate.
29581e934351Sopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getCertificate.
29591e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
29601e934351Sopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
29611e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
29621e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29631e934351Sopenharmony_ci     * @since 9
29641e934351Sopenharmony_ci     */
29651e934351Sopenharmony_ci    /**
29661e934351Sopenharmony_ci     * Returns an object representing a local certificate.
29671e934351Sopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getCertificate.
29681e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
29691e934351Sopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
29701e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
29711e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29721e934351Sopenharmony_ci     * @crossplatform
29731e934351Sopenharmony_ci     * @since 10
29741e934351Sopenharmony_ci     */
29751e934351Sopenharmony_ci    getCertificate(callback: AsyncCallback<X509CertRawData>): void;
29761e934351Sopenharmony_ci
29771e934351Sopenharmony_ci    /**
29781e934351Sopenharmony_ci     * Returns an object representing a local certificate.
29791e934351Sopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
29801e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
29811e934351Sopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
29821e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
29831e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29841e934351Sopenharmony_ci     * @since 9
29851e934351Sopenharmony_ci     */
29861e934351Sopenharmony_ci    /**
29871e934351Sopenharmony_ci     * Returns an object representing a local certificate.
29881e934351Sopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
29891e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
29901e934351Sopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
29911e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
29921e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
29931e934351Sopenharmony_ci     * @crossplatform
29941e934351Sopenharmony_ci     * @since 10
29951e934351Sopenharmony_ci     */
29961e934351Sopenharmony_ci    getCertificate(): Promise<X509CertRawData>;
29971e934351Sopenharmony_ci
29981e934351Sopenharmony_ci    /**
29991e934351Sopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
30001e934351Sopenharmony_ci     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
30011e934351Sopenharmony_ci     * It only contains the peer's certificate.
30021e934351Sopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getRemoteCertificate.
30031e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30041e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
30051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30061e934351Sopenharmony_ci     * @since 9
30071e934351Sopenharmony_ci     */
30081e934351Sopenharmony_ci    /**
30091e934351Sopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
30101e934351Sopenharmony_ci     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
30111e934351Sopenharmony_ci     * It only contains the peer's certificate.
30121e934351Sopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getRemoteCertificate.
30131e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30141e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
30151e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30161e934351Sopenharmony_ci     * @crossplatform
30171e934351Sopenharmony_ci     * @since 10
30181e934351Sopenharmony_ci     */
30191e934351Sopenharmony_ci    getRemoteCertificate(callback: AsyncCallback<X509CertRawData>): void;
30201e934351Sopenharmony_ci
30211e934351Sopenharmony_ci    /**
30221e934351Sopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
30231e934351Sopenharmony_ci     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
30241e934351Sopenharmony_ci     * It only contains the peer's certificate.
30251e934351Sopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
30261e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30271e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
30281e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30291e934351Sopenharmony_ci     * @since 9
30301e934351Sopenharmony_ci     */
30311e934351Sopenharmony_ci    /**
30321e934351Sopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
30331e934351Sopenharmony_ci     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
30341e934351Sopenharmony_ci     * It only contains the peer's certificate.
30351e934351Sopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
30361e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30371e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
30381e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30391e934351Sopenharmony_ci     * @crossplatform
30401e934351Sopenharmony_ci     * @since 10
30411e934351Sopenharmony_ci     */
30421e934351Sopenharmony_ci    getRemoteCertificate(): Promise<X509CertRawData>;
30431e934351Sopenharmony_ci
30441e934351Sopenharmony_ci    /**
30451e934351Sopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
30461e934351Sopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
30471e934351Sopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
30481e934351Sopenharmony_ci     * @param { AsyncCallback<string> } callback - the callback of getProtocol.
30491e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30501e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
30511e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
30521e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30531e934351Sopenharmony_ci     * @since 9
30541e934351Sopenharmony_ci     */
30551e934351Sopenharmony_ci    /**
30561e934351Sopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
30571e934351Sopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
30581e934351Sopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
30591e934351Sopenharmony_ci     * @param { AsyncCallback<string> } callback - the callback of getProtocol.
30601e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30611e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
30621e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
30631e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30641e934351Sopenharmony_ci     * @crossplatform
30651e934351Sopenharmony_ci     * @since 10
30661e934351Sopenharmony_ci     */
30671e934351Sopenharmony_ci    getProtocol(callback: AsyncCallback<string>): void;
30681e934351Sopenharmony_ci
30691e934351Sopenharmony_ci    /**
30701e934351Sopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
30711e934351Sopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
30721e934351Sopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
30731e934351Sopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
30741e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30751e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
30761e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
30771e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30781e934351Sopenharmony_ci     * @since 9
30791e934351Sopenharmony_ci     */
30801e934351Sopenharmony_ci    /**
30811e934351Sopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
30821e934351Sopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
30831e934351Sopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
30841e934351Sopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
30851e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30861e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
30871e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
30881e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
30891e934351Sopenharmony_ci     * @crossplatform
30901e934351Sopenharmony_ci     * @since 10
30911e934351Sopenharmony_ci     */
30921e934351Sopenharmony_ci    getProtocol(): Promise<string>;
30931e934351Sopenharmony_ci
30941e934351Sopenharmony_ci    /**
30951e934351Sopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
30961e934351Sopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
30971e934351Sopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - the callback of getCipherSuite.
30981e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
30991e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
31001e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
31011e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
31021e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31031e934351Sopenharmony_ci     * @since 9
31041e934351Sopenharmony_ci     */
31051e934351Sopenharmony_ci    /**
31061e934351Sopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
31071e934351Sopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
31081e934351Sopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - the callback of getCipherSuite.
31091e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
31101e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
31111e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
31121e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
31131e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31141e934351Sopenharmony_ci     * @crossplatform
31151e934351Sopenharmony_ci     * @since 10
31161e934351Sopenharmony_ci     */
31171e934351Sopenharmony_ci    getCipherSuite(callback: AsyncCallback<Array<string>>): void;
31181e934351Sopenharmony_ci
31191e934351Sopenharmony_ci    /**
31201e934351Sopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
31211e934351Sopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
31221e934351Sopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.
31231e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
31241e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
31251e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
31261e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
31271e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31281e934351Sopenharmony_ci     * @since 9
31291e934351Sopenharmony_ci     */
31301e934351Sopenharmony_ci    /**
31311e934351Sopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
31321e934351Sopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
31331e934351Sopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.
31341e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
31351e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
31361e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
31371e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
31381e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31391e934351Sopenharmony_ci     * @crossplatform
31401e934351Sopenharmony_ci     * @since 10
31411e934351Sopenharmony_ci     */
31421e934351Sopenharmony_ci    getCipherSuite(): Promise<Array<string>>;
31431e934351Sopenharmony_ci
31441e934351Sopenharmony_ci    /**
31451e934351Sopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
31461e934351Sopenharmony_ci     * in descending order of priority.</p>
31471e934351Sopenharmony_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
31481e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
31491e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
31501e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31511e934351Sopenharmony_ci     * @since 9
31521e934351Sopenharmony_ci     */
31531e934351Sopenharmony_ci    /**
31541e934351Sopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
31551e934351Sopenharmony_ci     * in descending order of priority.</p>
31561e934351Sopenharmony_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
31571e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
31581e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
31591e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31601e934351Sopenharmony_ci     * @crossplatform
31611e934351Sopenharmony_ci     * @since 10
31621e934351Sopenharmony_ci     */
31631e934351Sopenharmony_ci    getSignatureAlgorithms(callback: AsyncCallback<Array<string>>): void;
31641e934351Sopenharmony_ci
31651e934351Sopenharmony_ci    /**
31661e934351Sopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
31671e934351Sopenharmony_ci     * in descending order of priority.</p>
31681e934351Sopenharmony_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
31691e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
31701e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
31711e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31721e934351Sopenharmony_ci     * @since 9
31731e934351Sopenharmony_ci     */
31741e934351Sopenharmony_ci    /**
31751e934351Sopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
31761e934351Sopenharmony_ci     * in descending order of priority.</p>
31771e934351Sopenharmony_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
31781e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
31791e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
31801e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
31811e934351Sopenharmony_ci     * @crossplatform
31821e934351Sopenharmony_ci     * @since 10
31831e934351Sopenharmony_ci     */
31841e934351Sopenharmony_ci    getSignatureAlgorithms(): Promise<Array<string>>;
31851e934351Sopenharmony_ci
31861e934351Sopenharmony_ci    /**
31871e934351Sopenharmony_ci     * Sets up a connection to the specified IP address and port number.
31881e934351Sopenharmony_ci     * Only TCP is supported.
31891e934351Sopenharmony_ci     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
31901e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of connect.
31911e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
31921e934351Sopenharmony_ci     * @throws { BusinessError } 2303104 - Interrupted system call.
31931e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
31941e934351Sopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
31951e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
31961e934351Sopenharmony_ci     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
31971e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
31981e934351Sopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
31991e934351Sopenharmony_ci     * @throws { BusinessError } 2303210 - Connection timed out.
32001e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
32011e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
32021e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
32031e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
32041e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
32051e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
32061e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
32071e934351Sopenharmony_ci     * @since 9
32081e934351Sopenharmony_ci     */
32091e934351Sopenharmony_ci    /**
32101e934351Sopenharmony_ci     * Sets up a connection to the specified IP address and port number.
32111e934351Sopenharmony_ci     * Only TCP is supported.
32121e934351Sopenharmony_ci     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
32131e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of connect.
32141e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
32151e934351Sopenharmony_ci     * @throws { BusinessError } 2303104 - Interrupted system call.
32161e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
32171e934351Sopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
32181e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
32191e934351Sopenharmony_ci     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
32201e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
32211e934351Sopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
32221e934351Sopenharmony_ci     * @throws { BusinessError } 2303210 - Connection timed out.
32231e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
32241e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
32251e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
32261e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
32271e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
32281e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
32291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
32301e934351Sopenharmony_ci     * @crossplatform
32311e934351Sopenharmony_ci     * @since 10
32321e934351Sopenharmony_ci     */
32331e934351Sopenharmony_ci    connect(options: TLSConnectOptions, callback: AsyncCallback<void>): void;
32341e934351Sopenharmony_ci
32351e934351Sopenharmony_ci    /**
32361e934351Sopenharmony_ci     * Sets up a connection to the specified IP address and port number.
32371e934351Sopenharmony_ci     * Only TCP is supported.
32381e934351Sopenharmony_ci     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
32391e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
32401e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
32411e934351Sopenharmony_ci     * @throws { BusinessError } 2303104 - Interrupted system call.
32421e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
32431e934351Sopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
32441e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
32451e934351Sopenharmony_ci     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
32461e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
32471e934351Sopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
32481e934351Sopenharmony_ci     * @throws { BusinessError } 2303210 - Connection timed out.
32491e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
32501e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
32511e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
32521e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
32531e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
32541e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
32551e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
32561e934351Sopenharmony_ci     * @since 9
32571e934351Sopenharmony_ci     */
32581e934351Sopenharmony_ci    /**
32591e934351Sopenharmony_ci     * Sets up a connection to the specified IP address and port number.
32601e934351Sopenharmony_ci     * Only TCP is supported.
32611e934351Sopenharmony_ci     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
32621e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
32631e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
32641e934351Sopenharmony_ci     * @throws { BusinessError } 2303104 - Interrupted system call.
32651e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
32661e934351Sopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
32671e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
32681e934351Sopenharmony_ci     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
32691e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
32701e934351Sopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
32711e934351Sopenharmony_ci     * @throws { BusinessError } 2303210 - Connection timed out.
32721e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
32731e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
32741e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
32751e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
32761e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
32771e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
32781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
32791e934351Sopenharmony_ci     * @crossplatform
32801e934351Sopenharmony_ci     * @since 10
32811e934351Sopenharmony_ci     */
32821e934351Sopenharmony_ci    connect(options: TLSConnectOptions): Promise<void>;
32831e934351Sopenharmony_ci
32841e934351Sopenharmony_ci    /**
32851e934351Sopenharmony_ci     * Sends data over a TLSSocket connection.
32861e934351Sopenharmony_ci     * @param { string } data - Parameters for sending data {@link string}.
32871e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
32881e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
32891e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
32901e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
32911e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
32921e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
32931e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
32941e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
32951e934351Sopenharmony_ci     * @since 9
32961e934351Sopenharmony_ci     */
32971e934351Sopenharmony_ci    /**
32981e934351Sopenharmony_ci     * Sends data over a TLSSocket connection.
32991e934351Sopenharmony_ci     * @param { string } data - Parameters for sending data {@link string}.
33001e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
33011e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
33021e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
33031e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
33041e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
33051e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
33061e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
33071e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
33081e934351Sopenharmony_ci     * @crossplatform
33091e934351Sopenharmony_ci     * @since 10
33101e934351Sopenharmony_ci     */
33111e934351Sopenharmony_ci    /**
33121e934351Sopenharmony_ci     * Sends data over a TLSSocket connection.
33131e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Parameters for sending data.
33141e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of send.
33151e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
33161e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
33171e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
33181e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
33191e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
33201e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
33211e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
33221e934351Sopenharmony_ci     * @crossplatform
33231e934351Sopenharmony_ci     * @since 12
33241e934351Sopenharmony_ci     */
33251e934351Sopenharmony_ci    send(data: string | ArrayBuffer, callback: AsyncCallback<void>): void;
33261e934351Sopenharmony_ci
33271e934351Sopenharmony_ci    /**
33281e934351Sopenharmony_ci     * Sends data over a TLSSocket connection.
33291e934351Sopenharmony_ci     * @param { string } data - Parameters for sending data {@link string}.
33301e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
33311e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
33321e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
33331e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
33341e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
33351e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
33361e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
33371e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
33381e934351Sopenharmony_ci     * @since 9
33391e934351Sopenharmony_ci     */
33401e934351Sopenharmony_ci    /**
33411e934351Sopenharmony_ci     * Sends data over a TLSSocket connection.
33421e934351Sopenharmony_ci     * @param { string } data - Parameters for sending data {@link string}.
33431e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
33441e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
33451e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
33461e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
33471e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
33481e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
33491e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
33501e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
33511e934351Sopenharmony_ci     * @crossplatform
33521e934351Sopenharmony_ci     * @since 10
33531e934351Sopenharmony_ci     */
33541e934351Sopenharmony_ci    /**
33551e934351Sopenharmony_ci     * Sends data over a TLSSocket connection.
33561e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Parameters for sending data.
33571e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
33581e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
33591e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
33601e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
33611e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
33621e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
33631e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
33641e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
33651e934351Sopenharmony_ci     * @crossplatform
33661e934351Sopenharmony_ci     * @since 12
33671e934351Sopenharmony_ci     */
33681e934351Sopenharmony_ci    send(data: string | ArrayBuffer): Promise<void>;
33691e934351Sopenharmony_ci
33701e934351Sopenharmony_ci    /**
33711e934351Sopenharmony_ci     * Closes a TLSSocket connection
33721e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
33731e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
33741e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
33751e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
33761e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
33771e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
33781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
33791e934351Sopenharmony_ci     * @since 9
33801e934351Sopenharmony_ci     */
33811e934351Sopenharmony_ci    /**
33821e934351Sopenharmony_ci     * Closes a TLSSocket connection
33831e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - the callback of close.
33841e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
33851e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
33861e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
33871e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
33881e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
33891e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
33901e934351Sopenharmony_ci     * @crossplatform
33911e934351Sopenharmony_ci     * @since 10
33921e934351Sopenharmony_ci     */
33931e934351Sopenharmony_ci    close(callback: AsyncCallback<void>): void;
33941e934351Sopenharmony_ci
33951e934351Sopenharmony_ci    /**
33961e934351Sopenharmony_ci     * Closes a TLSSocket connection
33971e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
33981e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
33991e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
34001e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
34011e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
34021e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
34031e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34041e934351Sopenharmony_ci     * @since 9
34051e934351Sopenharmony_ci     */
34061e934351Sopenharmony_ci    /**
34071e934351Sopenharmony_ci     * Closes a TLSSocket connection
34081e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
34091e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
34101e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
34111e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
34121e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
34131e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
34141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34151e934351Sopenharmony_ci     * @crossplatform
34161e934351Sopenharmony_ci     * @since 10
34171e934351Sopenharmony_ci     */
34181e934351Sopenharmony_ci    close(): Promise<void>;
34191e934351Sopenharmony_ci  }
34201e934351Sopenharmony_ci
34211e934351Sopenharmony_ci  /**
34221e934351Sopenharmony_ci   * Defines TLS security options. The CA certificate is mandatory, and other parameters are optional.
34231e934351Sopenharmony_ci   * @interface TLSSecureOptions
34241e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
34251e934351Sopenharmony_ci   * @since 9
34261e934351Sopenharmony_ci   */
34271e934351Sopenharmony_ci  /**
34281e934351Sopenharmony_ci   * Defines TLS security options. The CA certificate is mandatory, and other parameters are optional.
34291e934351Sopenharmony_ci   * @interface TLSSecureOptions
34301e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
34311e934351Sopenharmony_ci   * @crossplatform
34321e934351Sopenharmony_ci   * @since 10
34331e934351Sopenharmony_ci   */
34341e934351Sopenharmony_ci  export interface TLSSecureOptions {
34351e934351Sopenharmony_ci    /**
34361e934351Sopenharmony_ci     * Certificate used to verify the identity of the server
34371e934351Sopenharmony_ci     * @type {string | Array<string>}
34381e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34391e934351Sopenharmony_ci     * @since 9
34401e934351Sopenharmony_ci     */
34411e934351Sopenharmony_ci    /**
34421e934351Sopenharmony_ci     * Certificate used to verify the identity of the server.
34431e934351Sopenharmony_ci     * @type {string | Array<string>}
34441e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34451e934351Sopenharmony_ci     * @crossplatform
34461e934351Sopenharmony_ci     * @since 10
34471e934351Sopenharmony_ci     */
34481e934351Sopenharmony_ci    /**
34491e934351Sopenharmony_ci     * Certificate used to verify the identity of the server, if it is not set, use system ca.
34501e934351Sopenharmony_ci     * @type {?(string | Array<string>)}
34511e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34521e934351Sopenharmony_ci     * @crossplatform
34531e934351Sopenharmony_ci     * @since 12
34541e934351Sopenharmony_ci     */
34551e934351Sopenharmony_ci    ca?: string | Array<string>;
34561e934351Sopenharmony_ci
34571e934351Sopenharmony_ci    /**
34581e934351Sopenharmony_ci     * Certificate proving the identity of the client
34591e934351Sopenharmony_ci     * @type {?string}
34601e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34611e934351Sopenharmony_ci     * @since 9
34621e934351Sopenharmony_ci     */
34631e934351Sopenharmony_ci    /**
34641e934351Sopenharmony_ci     * Certificate proving the identity of the client
34651e934351Sopenharmony_ci     * @type {?string}
34661e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34671e934351Sopenharmony_ci     * @crossplatform
34681e934351Sopenharmony_ci     * @since 10
34691e934351Sopenharmony_ci     */
34701e934351Sopenharmony_ci    cert?: string;
34711e934351Sopenharmony_ci
34721e934351Sopenharmony_ci    /**
34731e934351Sopenharmony_ci     * Private key of client certificate
34741e934351Sopenharmony_ci     * @type {?string}
34751e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34761e934351Sopenharmony_ci     * @since 9
34771e934351Sopenharmony_ci     */
34781e934351Sopenharmony_ci    /**
34791e934351Sopenharmony_ci     * Private key of client certificate
34801e934351Sopenharmony_ci     * @type {?string}
34811e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34821e934351Sopenharmony_ci     * @crossplatform
34831e934351Sopenharmony_ci     * @since 10
34841e934351Sopenharmony_ci     */
34851e934351Sopenharmony_ci    key?: string;
34861e934351Sopenharmony_ci
34871e934351Sopenharmony_ci    /**
34881e934351Sopenharmony_ci     * Password of the private key
34891e934351Sopenharmony_ci     * @type {?string}
34901e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34911e934351Sopenharmony_ci     * @since 9
34921e934351Sopenharmony_ci     */
34931e934351Sopenharmony_ci    /**
34941e934351Sopenharmony_ci     * Password of the private key
34951e934351Sopenharmony_ci     * @type {?string}
34961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
34971e934351Sopenharmony_ci     * @crossplatform
34981e934351Sopenharmony_ci     * @since 10
34991e934351Sopenharmony_ci     */
35001e934351Sopenharmony_ci    password?: string;
35011e934351Sopenharmony_ci
35021e934351Sopenharmony_ci    /**
35031e934351Sopenharmony_ci     * TLS protocol version
35041e934351Sopenharmony_ci     * @type {?Protocol | Array<Protocol>}
35051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35061e934351Sopenharmony_ci     * @since 9
35071e934351Sopenharmony_ci     */
35081e934351Sopenharmony_ci    /**
35091e934351Sopenharmony_ci     * TLS protocol version
35101e934351Sopenharmony_ci     * @type {?(Protocol | Array<Protocol>)}
35111e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35121e934351Sopenharmony_ci     * @crossplatform
35131e934351Sopenharmony_ci     * @since 10
35141e934351Sopenharmony_ci     */
35151e934351Sopenharmony_ci    protocols?: Protocol | Array<Protocol>;
35161e934351Sopenharmony_ci
35171e934351Sopenharmony_ci    /**
35181e934351Sopenharmony_ci     * default is false, use local cipher.
35191e934351Sopenharmony_ci     * @type {?boolean}
35201e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35211e934351Sopenharmony_ci     * @since 9
35221e934351Sopenharmony_ci     */
35231e934351Sopenharmony_ci    /**
35241e934351Sopenharmony_ci     * default is false, use local cipher.
35251e934351Sopenharmony_ci     * @type {?boolean}
35261e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35271e934351Sopenharmony_ci     * @crossplatform
35281e934351Sopenharmony_ci     * @since 10
35291e934351Sopenharmony_ci     */
35301e934351Sopenharmony_ci    useRemoteCipherPrefer?: boolean;
35311e934351Sopenharmony_ci
35321e934351Sopenharmony_ci    /**
35331e934351Sopenharmony_ci     * <P>Supported signature algorithms. This string can contain summary algorithms(SHA256,MD5,etc),Public key algorithm(RSA-PSS,ECDSA,etc),
35341e934351Sopenharmony_ci     * Combination of the two(For example 'RSA+SHA384') or TLS v1.3 Scheme name(For example  rsa_pss_pss_sha512)</P>
35351e934351Sopenharmony_ci     * @type {?string}
35361e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35371e934351Sopenharmony_ci     * @since 9
35381e934351Sopenharmony_ci     */
35391e934351Sopenharmony_ci    /**
35401e934351Sopenharmony_ci     * <P>Supported signature algorithms. This string can contain summary algorithms(SHA256,MD5,etc),Public key algorithm(RSA-PSS,ECDSA,etc),
35411e934351Sopenharmony_ci     * Combination of the two(For example 'RSA+SHA384') or TLS v1.3 Scheme name(For example  rsa_pss_pss_sha512)</P>
35421e934351Sopenharmony_ci     * @type {?string}
35431e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35441e934351Sopenharmony_ci     * @crossplatform
35451e934351Sopenharmony_ci     * @since 10
35461e934351Sopenharmony_ci     */
35471e934351Sopenharmony_ci    signatureAlgorithms?: string;
35481e934351Sopenharmony_ci
35491e934351Sopenharmony_ci    /**
35501e934351Sopenharmony_ci     * Crypto suite specification
35511e934351Sopenharmony_ci     * @type {?string}
35521e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35531e934351Sopenharmony_ci     * @since 9
35541e934351Sopenharmony_ci     */
35551e934351Sopenharmony_ci    /**
35561e934351Sopenharmony_ci     * Crypto suite specification
35571e934351Sopenharmony_ci     * @type {?string}
35581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35591e934351Sopenharmony_ci     * @crossplatform
35601e934351Sopenharmony_ci     * @since 10
35611e934351Sopenharmony_ci     */
35621e934351Sopenharmony_ci    cipherSuite?: string;
35631e934351Sopenharmony_ci
35641e934351Sopenharmony_ci    /**
35651e934351Sopenharmony_ci     * Used to set up bidirectional authentication. The default value is false.
35661e934351Sopenharmony_ci     * @type {?boolean}
35671e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35681e934351Sopenharmony_ci     * @since 12
35691e934351Sopenharmony_ci     */
35701e934351Sopenharmony_ci    isBidirectionalAuthentication?: boolean;
35711e934351Sopenharmony_ci  }
35721e934351Sopenharmony_ci
35731e934351Sopenharmony_ci  /**
35741e934351Sopenharmony_ci   * Defines TLS connection options.
35751e934351Sopenharmony_ci   * @interface TLSConnectOptions
35761e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
35771e934351Sopenharmony_ci   * @since 9
35781e934351Sopenharmony_ci   */
35791e934351Sopenharmony_ci  /**
35801e934351Sopenharmony_ci   * Defines TLS connection options.
35811e934351Sopenharmony_ci   * @interface TLSConnectOptions
35821e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
35831e934351Sopenharmony_ci   * @crossplatform
35841e934351Sopenharmony_ci   * @since 10
35851e934351Sopenharmony_ci   */
35861e934351Sopenharmony_ci  export interface TLSConnectOptions {
35871e934351Sopenharmony_ci    /**
35881e934351Sopenharmony_ci     * Gateway address.
35891e934351Sopenharmony_ci     * @type {NetAddress}
35901e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35911e934351Sopenharmony_ci     * @since 9
35921e934351Sopenharmony_ci     */
35931e934351Sopenharmony_ci    /**
35941e934351Sopenharmony_ci     * Gateway address.
35951e934351Sopenharmony_ci     * @type {NetAddress}
35961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
35971e934351Sopenharmony_ci     * @crossplatform
35981e934351Sopenharmony_ci     * @since 10
35991e934351Sopenharmony_ci     */
36001e934351Sopenharmony_ci    address: NetAddress;
36011e934351Sopenharmony_ci
36021e934351Sopenharmony_ci    /**
36031e934351Sopenharmony_ci     * Protocol http2TLS security related operations.
36041e934351Sopenharmony_ci     * @type {TLSSecureOptions}
36051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36061e934351Sopenharmony_ci     * @since 9
36071e934351Sopenharmony_ci     */
36081e934351Sopenharmony_ci    /**
36091e934351Sopenharmony_ci     * Protocol http2TLS security related operations.
36101e934351Sopenharmony_ci     * @type {TLSSecureOptions}
36111e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36121e934351Sopenharmony_ci     * @crossplatform
36131e934351Sopenharmony_ci     * @since 10
36141e934351Sopenharmony_ci     */
36151e934351Sopenharmony_ci    secureOptions: TLSSecureOptions;
36161e934351Sopenharmony_ci
36171e934351Sopenharmony_ci    /**
36181e934351Sopenharmony_ci     * Application layer protocol negotiation extension, such as "spdy/1", "http/1.1", "h2"
36191e934351Sopenharmony_ci     * @type {?Array<string>}
36201e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36211e934351Sopenharmony_ci     * @since 9
36221e934351Sopenharmony_ci     */
36231e934351Sopenharmony_ci    /**
36241e934351Sopenharmony_ci     * Application layer protocol negotiation extension, such as "spdy/1", "http/1.1", "h2"
36251e934351Sopenharmony_ci     * @type {?Array<string>}
36261e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36271e934351Sopenharmony_ci     * @crossplatform
36281e934351Sopenharmony_ci     * @since 10
36291e934351Sopenharmony_ci     */
36301e934351Sopenharmony_ci    ALPNProtocols?: Array<string>;
36311e934351Sopenharmony_ci
36321e934351Sopenharmony_ci    /**
36331e934351Sopenharmony_ci     * Skip identity verification for remote servers. The default value is false.
36341e934351Sopenharmony_ci     * @type {?boolean}
36351e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36361e934351Sopenharmony_ci     * @since 12
36371e934351Sopenharmony_ci     */
36381e934351Sopenharmony_ci    skipRemoteValidation?: boolean;
36391e934351Sopenharmony_ci  }
36401e934351Sopenharmony_ci
36411e934351Sopenharmony_ci  /**
36421e934351Sopenharmony_ci   * Enumerates TLS protocol versions.
36431e934351Sopenharmony_ci   * @enum {string}
36441e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
36451e934351Sopenharmony_ci   * @since 9
36461e934351Sopenharmony_ci   */
36471e934351Sopenharmony_ci  /**
36481e934351Sopenharmony_ci   * Enumerates TLS protocol versions.
36491e934351Sopenharmony_ci   * @enum {string}
36501e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
36511e934351Sopenharmony_ci   * @crossplatform
36521e934351Sopenharmony_ci   * @since 10
36531e934351Sopenharmony_ci   */
36541e934351Sopenharmony_ci  export enum Protocol {
36551e934351Sopenharmony_ci    /**
36561e934351Sopenharmony_ci     * Use TLSv1.2 protocol for communication.
36571e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36581e934351Sopenharmony_ci     * @since 9
36591e934351Sopenharmony_ci     */
36601e934351Sopenharmony_ci    /**
36611e934351Sopenharmony_ci     * Use TLSv1.2 protocol for communication.
36621e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36631e934351Sopenharmony_ci     * @crossplatform
36641e934351Sopenharmony_ci     * @since 10
36651e934351Sopenharmony_ci     */
36661e934351Sopenharmony_ci    TLSv12 = "TLSv1.2",
36671e934351Sopenharmony_ci
36681e934351Sopenharmony_ci    /**
36691e934351Sopenharmony_ci     * Use TLSv1.3 protocol for communication.
36701e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36711e934351Sopenharmony_ci     * @since 9
36721e934351Sopenharmony_ci     */
36731e934351Sopenharmony_ci    /**
36741e934351Sopenharmony_ci     * Use TLSv1.3 protocol for communication.
36751e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36761e934351Sopenharmony_ci     * @crossplatform
36771e934351Sopenharmony_ci     * @since 10
36781e934351Sopenharmony_ci     */
36791e934351Sopenharmony_ci    TLSv13 = "TLSv1.3"
36801e934351Sopenharmony_ci  }
36811e934351Sopenharmony_ci
36821e934351Sopenharmony_ci  /**
36831e934351Sopenharmony_ci   * Defines the connection of the TCPSocket client and server.
36841e934351Sopenharmony_ci   * @interface TCPSocketConnection
36851e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
36861e934351Sopenharmony_ci   * @since 10
36871e934351Sopenharmony_ci   */
36881e934351Sopenharmony_ci  export interface TCPSocketConnection {
36891e934351Sopenharmony_ci    /**
36901e934351Sopenharmony_ci     * The id of a client connects to the TCPSocketServer.
36911e934351Sopenharmony_ci     * @type {number}
36921e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
36931e934351Sopenharmony_ci     * @since 10
36941e934351Sopenharmony_ci     */
36951e934351Sopenharmony_ci    clientId: number;
36961e934351Sopenharmony_ci
36971e934351Sopenharmony_ci    /**
36981e934351Sopenharmony_ci     * Sends data over a TCPSocketServer connection to client.
36991e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
37001e934351Sopenharmony_ci     * @param { TCPSendOptions } options - Parameters for sending data {@link TCPSendOptions}.
37011e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of send.
37021e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
37031e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
37041e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
37051e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37061e934351Sopenharmony_ci     * @since 10
37071e934351Sopenharmony_ci     */
37081e934351Sopenharmony_ci    send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
37091e934351Sopenharmony_ci
37101e934351Sopenharmony_ci    /**
37111e934351Sopenharmony_ci     * Sends data over a TCPSocketServer connection to client.
37121e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
37131e934351Sopenharmony_ci     * @param { TCPSendOptions } options - Parameters for sending data {@link TCPSendOptions}.
37141e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
37151e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
37161e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
37171e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
37181e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37191e934351Sopenharmony_ci     * @since 10
37201e934351Sopenharmony_ci     */
37211e934351Sopenharmony_ci    send(options: TCPSendOptions): Promise<void>;
37221e934351Sopenharmony_ci
37231e934351Sopenharmony_ci    /**
37241e934351Sopenharmony_ci     * Closes a TCPSocket client connection.
37251e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
37261e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of close.
37271e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
37281e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
37291e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
37301e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37311e934351Sopenharmony_ci     * @since 10
37321e934351Sopenharmony_ci     */
37331e934351Sopenharmony_ci    close(callback: AsyncCallback<void>): void;
37341e934351Sopenharmony_ci
37351e934351Sopenharmony_ci    /**
37361e934351Sopenharmony_ci     * Closes a TCPSocket client connection.
37371e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
37381e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
37391e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
37401e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
37411e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37421e934351Sopenharmony_ci     * @since 10
37431e934351Sopenharmony_ci     */
37441e934351Sopenharmony_ci    close(): Promise<void>;
37451e934351Sopenharmony_ci
37461e934351Sopenharmony_ci    /**
37471e934351Sopenharmony_ci     * Obtains the peer address of a TCPSocketServer connection.
37481e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
37491e934351Sopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - The callback of getRemoteAddress.
37501e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
37511e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
37521e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
37531e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
37541e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37551e934351Sopenharmony_ci     * @since 10
37561e934351Sopenharmony_ci     */
37571e934351Sopenharmony_ci    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
37581e934351Sopenharmony_ci
37591e934351Sopenharmony_ci    /**
37601e934351Sopenharmony_ci     * Obtains the peer address of a TCPSocketServer connection.
37611e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
37621e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
37631e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
37641e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
37651e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
37661e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37671e934351Sopenharmony_ci     * @since 10
37681e934351Sopenharmony_ci     */
37691e934351Sopenharmony_ci    getRemoteAddress(): Promise<NetAddress>;
37701e934351Sopenharmony_ci
37711e934351Sopenharmony_ci    /**
37721e934351Sopenharmony_ci     * Obtains the local address of a TCPSocketServer connection.
37731e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
37741e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
37751e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
37761e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
37771e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37781e934351Sopenharmony_ci     * @since 12
37791e934351Sopenharmony_ci     */
37801e934351Sopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
37811e934351Sopenharmony_ci
37821e934351Sopenharmony_ci    /**
37831e934351Sopenharmony_ci     * Listens for message receiving events of the TCPSocketConnection.
37841e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
37851e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of on.
37861e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
37871e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37881e934351Sopenharmony_ci     * @since 10
37891e934351Sopenharmony_ci     */
37901e934351Sopenharmony_ci    /**
37911e934351Sopenharmony_ci     * Listens for message receiving events of the TCPSocketConnection.
37921e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
37931e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
37941e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
37951e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
37961e934351Sopenharmony_ci     * @since 11
37971e934351Sopenharmony_ci     */
37981e934351Sopenharmony_ci    /**
37991e934351Sopenharmony_ci     * Listens for message receiving events of the TCPSocketConnection.
38001e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
38011e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
38021e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38031e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38041e934351Sopenharmony_ci     * @crossplatform
38051e934351Sopenharmony_ci     * @since 12
38061e934351Sopenharmony_ci     */
38071e934351Sopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
38081e934351Sopenharmony_ci
38091e934351Sopenharmony_ci    /**
38101e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TCPSocketConnection.
38111e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
38121e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of off.
38131e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38151e934351Sopenharmony_ci     * @since 10
38161e934351Sopenharmony_ci     */
38171e934351Sopenharmony_ci    /**
38181e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TCPSocketConnection.
38191e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
38201e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
38211e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38221e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38231e934351Sopenharmony_ci     * @since 11
38241e934351Sopenharmony_ci     */
38251e934351Sopenharmony_ci    /**
38261e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TCPSocketConnection.
38271e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
38281e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
38291e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38301e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38311e934351Sopenharmony_ci     * @crossplatform
38321e934351Sopenharmony_ci     * @since 12
38331e934351Sopenharmony_ci     */
38341e934351Sopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
38351e934351Sopenharmony_ci
38361e934351Sopenharmony_ci    /**
38371e934351Sopenharmony_ci     * Listens for close events of the TCPSocketConnection.
38381e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
38391e934351Sopenharmony_ci     * @param { Callback<void> } callback - The callback of on.
38401e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38411e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38421e934351Sopenharmony_ci     * @since 10
38431e934351Sopenharmony_ci     */
38441e934351Sopenharmony_ci    on(type: 'close', callback: Callback<void>): void;
38451e934351Sopenharmony_ci
38461e934351Sopenharmony_ci    /**
38471e934351Sopenharmony_ci     * Cancels listening for close events of the TCPSocketConnection.
38481e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
38491e934351Sopenharmony_ci     * @param { Callback<void> } callback - The callback of off.
38501e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38511e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38521e934351Sopenharmony_ci     * @since 10
38531e934351Sopenharmony_ci     */
38541e934351Sopenharmony_ci    off(type: 'close', callback?: Callback<void>): void;
38551e934351Sopenharmony_ci
38561e934351Sopenharmony_ci    /**
38571e934351Sopenharmony_ci     * Listens for error events of the TCPSocketConnection.
38581e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
38591e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
38601e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38611e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38621e934351Sopenharmony_ci     * @since 10
38631e934351Sopenharmony_ci     */
38641e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
38651e934351Sopenharmony_ci
38661e934351Sopenharmony_ci    /**
38671e934351Sopenharmony_ci     * Cancels listening for error events of the TCPSocketConnection.
38681e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
38691e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
38701e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38711e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38721e934351Sopenharmony_ci     * @since 10
38731e934351Sopenharmony_ci     */
38741e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
38751e934351Sopenharmony_ci  }
38761e934351Sopenharmony_ci
38771e934351Sopenharmony_ci  /**
38781e934351Sopenharmony_ci   * Defines a TCPSocket server connection.
38791e934351Sopenharmony_ci   * @interface TCPSocketServer
38801e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
38811e934351Sopenharmony_ci   * @since 10
38821e934351Sopenharmony_ci   */
38831e934351Sopenharmony_ci  export interface TCPSocketServer {
38841e934351Sopenharmony_ci    /**
38851e934351Sopenharmony_ci     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
38861e934351Sopenharmony_ci     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
38871e934351Sopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
38881e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
38891e934351Sopenharmony_ci     * @param { NetAddress } address - Network address information {@link NetAddress}.
38901e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of listen.
38911e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
38921e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
38931e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
38941e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
38951e934351Sopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
38961e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
38971e934351Sopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
38981e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
38991e934351Sopenharmony_ci     * @since 10
39001e934351Sopenharmony_ci     */
39011e934351Sopenharmony_ci    listen(address: NetAddress, callback: AsyncCallback<void>): void;
39021e934351Sopenharmony_ci
39031e934351Sopenharmony_ci    /** 
39041e934351Sopenharmony_ci     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
39051e934351Sopenharmony_ci     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
39061e934351Sopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
39071e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
39081e934351Sopenharmony_ci     * @param { NetAddress } address - Network address information {@link NetAddress}.
39091e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
39101e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
39111e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
39121e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
39131e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
39141e934351Sopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
39151e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
39161e934351Sopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
39171e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
39181e934351Sopenharmony_ci     * @since 10
39191e934351Sopenharmony_ci     */
39201e934351Sopenharmony_ci    listen(address: NetAddress): Promise<void>;
39211e934351Sopenharmony_ci
39221e934351Sopenharmony_ci    /**
39231e934351Sopenharmony_ci     * Obtains the status of the TCPSocketServer connection.
39241e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
39251e934351Sopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - The callback of getState.
39261e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
39271e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
39281e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
39291e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
39301e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
39311e934351Sopenharmony_ci     * @since 10
39321e934351Sopenharmony_ci     */
39331e934351Sopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
39341e934351Sopenharmony_ci
39351e934351Sopenharmony_ci    /**
39361e934351Sopenharmony_ci     * Obtains the status of the TCPSocketServer connection.
39371e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
39381e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
39391e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
39401e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
39411e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
39421e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
39431e934351Sopenharmony_ci     * @since 10
39441e934351Sopenharmony_ci     */
39451e934351Sopenharmony_ci    getState(): Promise<SocketStateBase>;
39461e934351Sopenharmony_ci
39471e934351Sopenharmony_ci    /**
39481e934351Sopenharmony_ci     * Sets other attributes of the TCPSocketServer connection.
39491e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
39501e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
39511e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setExtraOptions.
39521e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
39531e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
39541e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
39551e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
39561e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
39571e934351Sopenharmony_ci     * @since 10
39581e934351Sopenharmony_ci     */
39591e934351Sopenharmony_ci    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
39601e934351Sopenharmony_ci
39611e934351Sopenharmony_ci    /**
39621e934351Sopenharmony_ci     * Sets other attributes of the TCPSocketServer connection.
39631e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
39641e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
39651e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
39661e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
39671e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
39681e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
39691e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
39701e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
39711e934351Sopenharmony_ci     * @since 10
39721e934351Sopenharmony_ci     */
39731e934351Sopenharmony_ci    setExtraOptions(options: TCPExtraOptions): Promise<void>;
39741e934351Sopenharmony_ci
39751e934351Sopenharmony_ci    /**
39761e934351Sopenharmony_ci     * Obtains the local address of a TCPSocketServer connection.
39771e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
39781e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
39791e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
39801e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
39811e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
39821e934351Sopenharmony_ci     * @since 12
39831e934351Sopenharmony_ci     */
39841e934351Sopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
39851e934351Sopenharmony_ci
39861e934351Sopenharmony_ci    /**
39871e934351Sopenharmony_ci     * Listens for connect events of the TCPSocketServer connection.
39881e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
39891e934351Sopenharmony_ci     * @param { Callback<TCPSocketConnection> } callback - The callback of on.
39901e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
39911e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
39921e934351Sopenharmony_ci     * @since 10
39931e934351Sopenharmony_ci     */
39941e934351Sopenharmony_ci    on(type: 'connect', callback: Callback<TCPSocketConnection>): void;
39951e934351Sopenharmony_ci
39961e934351Sopenharmony_ci    /**
39971e934351Sopenharmony_ci     * Cancels listening for connect events of the TCPSocketServer connection.
39981e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
39991e934351Sopenharmony_ci     * @param { Callback<TCPSocketConnection> } callback - The callback of off.
40001e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
40011e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40021e934351Sopenharmony_ci     * @since 10
40031e934351Sopenharmony_ci     */
40041e934351Sopenharmony_ci    off(type: 'connect', callback?: Callback<TCPSocketConnection>): void;
40051e934351Sopenharmony_ci
40061e934351Sopenharmony_ci    /**
40071e934351Sopenharmony_ci     * Listens for error events of the TCPSocketServer connection.
40081e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
40091e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
40101e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
40111e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40121e934351Sopenharmony_ci     * @since 10
40131e934351Sopenharmony_ci     */
40141e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
40151e934351Sopenharmony_ci
40161e934351Sopenharmony_ci    /**
40171e934351Sopenharmony_ci     * Cancels listening for error events of the TCPSocketServer connection.
40181e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
40191e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
40201e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
40211e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40221e934351Sopenharmony_ci     * @since 10
40231e934351Sopenharmony_ci     */
40241e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
40251e934351Sopenharmony_ci  }
40261e934351Sopenharmony_ci
40271e934351Sopenharmony_ci  /**
40281e934351Sopenharmony_ci   * Defines the connection of the TLSSocket client and server.
40291e934351Sopenharmony_ci   * @interface TLSSocketConnection
40301e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
40311e934351Sopenharmony_ci   * @since 10
40321e934351Sopenharmony_ci   */
40331e934351Sopenharmony_ci  export interface TLSSocketConnection {
40341e934351Sopenharmony_ci    /**
40351e934351Sopenharmony_ci     * The id of a client connects to the TLSSocketServer.
40361e934351Sopenharmony_ci     * @type {number}
40371e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40381e934351Sopenharmony_ci     * @since 10
40391e934351Sopenharmony_ci     */
40401e934351Sopenharmony_ci    clientId: number;
40411e934351Sopenharmony_ci
40421e934351Sopenharmony_ci    /**
40431e934351Sopenharmony_ci     * Sends data over a TLSSocketServer connection to client.
40441e934351Sopenharmony_ci     * @param { string } data - Parameters for sending data.
40451e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of send.
40461e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
40471e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
40481e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
40491e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
40501e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
40511e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
40521e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40531e934351Sopenharmony_ci     * @since 10
40541e934351Sopenharmony_ci     */
40551e934351Sopenharmony_ci    /**
40561e934351Sopenharmony_ci     * Sends data over a TLSSocketServer connection to client.
40571e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Parameters for sending data.
40581e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of send.
40591e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
40601e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
40611e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
40621e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
40631e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
40641e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
40651e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40661e934351Sopenharmony_ci     * @since 12
40671e934351Sopenharmony_ci     */
40681e934351Sopenharmony_ci    send(data: string | ArrayBuffer, callback: AsyncCallback<void>): void;
40691e934351Sopenharmony_ci
40701e934351Sopenharmony_ci    /**
40711e934351Sopenharmony_ci     * Sends data over a TLSSocketServer connection to client.
40721e934351Sopenharmony_ci     * @param { string } data - Parameters for sending data.
40731e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
40741e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
40751e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
40761e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
40771e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
40781e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
40791e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
40801e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40811e934351Sopenharmony_ci     * @since 10
40821e934351Sopenharmony_ci     */
40831e934351Sopenharmony_ci    /**
40841e934351Sopenharmony_ci     * Sends data over a TLSSocketServer connection to client.
40851e934351Sopenharmony_ci     * @param { string | ArrayBuffer } data - Parameters for sending data.
40861e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
40871e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
40881e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
40891e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
40901e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
40911e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
40921e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
40931e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
40941e934351Sopenharmony_ci     * @since 12
40951e934351Sopenharmony_ci     */
40961e934351Sopenharmony_ci    send(data: string | ArrayBuffer): Promise<void>;
40971e934351Sopenharmony_ci
40981e934351Sopenharmony_ci    /**
40991e934351Sopenharmony_ci     * Closes a TLSSocket client connection.
41001e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of close.
41011e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
41021e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
41031e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
41041e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
41051e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
41061e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41071e934351Sopenharmony_ci     * @since 10
41081e934351Sopenharmony_ci     */
41091e934351Sopenharmony_ci    close(callback: AsyncCallback<void>): void;
41101e934351Sopenharmony_ci
41111e934351Sopenharmony_ci    /**
41121e934351Sopenharmony_ci     * Closes a TLSSocket client connection.
41131e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
41141e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
41151e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
41161e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
41171e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
41181e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41191e934351Sopenharmony_ci     * @since 10
41201e934351Sopenharmony_ci     */
41211e934351Sopenharmony_ci    close(): Promise<void>;
41221e934351Sopenharmony_ci
41231e934351Sopenharmony_ci    /**
41241e934351Sopenharmony_ci     * Obtains the peer address of a TLSSocketServer connection.
41251e934351Sopenharmony_ci     * @param { AsyncCallback<NetAddress> } callback - The callback of getRemoteAddress.
41261e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
41271e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
41281e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
41291e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41301e934351Sopenharmony_ci     * @since 10
41311e934351Sopenharmony_ci     */
41321e934351Sopenharmony_ci    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
41331e934351Sopenharmony_ci
41341e934351Sopenharmony_ci    /**
41351e934351Sopenharmony_ci     * Obtains the peer address of a TLSSocketServer connection.
41361e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
41371e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
41381e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
41391e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41401e934351Sopenharmony_ci     * @since 10
41411e934351Sopenharmony_ci     */
41421e934351Sopenharmony_ci    getRemoteAddress(): Promise<NetAddress>;
41431e934351Sopenharmony_ci
41441e934351Sopenharmony_ci    /**
41451e934351Sopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
41461e934351Sopenharmony_ci     * an empty object will be returned. If the socket is destroyed, null is returned.</p>
41471e934351Sopenharmony_ci     * It only contains the peer's certificate.
41481e934351Sopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - The callback of getRemoteCertificate.
41491e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
41501e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
41511e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
41521e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41531e934351Sopenharmony_ci     * @since 10
41541e934351Sopenharmony_ci     */
41551e934351Sopenharmony_ci    getRemoteCertificate(callback: AsyncCallback<X509CertRawData>): void;
41561e934351Sopenharmony_ci
41571e934351Sopenharmony_ci    /**
41581e934351Sopenharmony_ci     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
41591e934351Sopenharmony_ci     * an empty object will be returned. If the socket is destroyed, null is returned.</p>
41601e934351Sopenharmony_ci     * It only contains the peer's certificate.
41611e934351Sopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
41621e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
41631e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
41641e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41651e934351Sopenharmony_ci     * @since 10
41661e934351Sopenharmony_ci     */
41671e934351Sopenharmony_ci    getRemoteCertificate(): Promise<X509CertRawData>;
41681e934351Sopenharmony_ci
41691e934351Sopenharmony_ci    /**
41701e934351Sopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
41711e934351Sopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
41721e934351Sopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - The callback of getCipherSuite.
41731e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
41741e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
41751e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
41761e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
41771e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
41781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41791e934351Sopenharmony_ci     * @since 10
41801e934351Sopenharmony_ci     */
41811e934351Sopenharmony_ci    getCipherSuite(callback: AsyncCallback<Array<string>>): void;
41821e934351Sopenharmony_ci
41831e934351Sopenharmony_ci    /**
41841e934351Sopenharmony_ci     * Returns a list containing the negotiated cipher suite information.
41851e934351Sopenharmony_ci     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
41861e934351Sopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.
41871e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
41881e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
41891e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
41901e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
41911e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
41921e934351Sopenharmony_ci     * @since 10
41931e934351Sopenharmony_ci     */
41941e934351Sopenharmony_ci    getCipherSuite(): Promise<Array<string>>;
41951e934351Sopenharmony_ci
41961e934351Sopenharmony_ci    /**
41971e934351Sopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
41981e934351Sopenharmony_ci     * in descending order of priority.</p>
41991e934351Sopenharmony_ci     * @param { AsyncCallback<Array<string>> } callback - The callback of getSignatureAlgorithms.
42001e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42011e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
42021e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
42031e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42041e934351Sopenharmony_ci     * @since 10
42051e934351Sopenharmony_ci     */
42061e934351Sopenharmony_ci    getSignatureAlgorithms(callback: AsyncCallback<Array<string>>): void;
42071e934351Sopenharmony_ci
42081e934351Sopenharmony_ci    /**
42091e934351Sopenharmony_ci     * <p>The list of signature algorithms shared between the server and the client,
42101e934351Sopenharmony_ci     * in descending order of priority.</p>
42111e934351Sopenharmony_ci     * @returns { Promise<Array<string>> } The promise returned by the function.
42121e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
42131e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
42141e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42151e934351Sopenharmony_ci     * @since 10
42161e934351Sopenharmony_ci     */
42171e934351Sopenharmony_ci    getSignatureAlgorithms(): Promise<Array<string>>;
42181e934351Sopenharmony_ci
42191e934351Sopenharmony_ci    /**
42201e934351Sopenharmony_ci     * Obtains the local address of a TLSSocketServer connection.
42211e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
42221e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
42231e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
42241e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
42251e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42261e934351Sopenharmony_ci     * @since 12
42271e934351Sopenharmony_ci     */
42281e934351Sopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
42291e934351Sopenharmony_ci
42301e934351Sopenharmony_ci    /**
42311e934351Sopenharmony_ci     * Listens for message receiving events of the TLSSocketConnection.
42321e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
42331e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of on.
42341e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42351e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42361e934351Sopenharmony_ci     * @since 10
42371e934351Sopenharmony_ci     */
42381e934351Sopenharmony_ci    /**
42391e934351Sopenharmony_ci     * Listens for message receiving events of the TLSSocketConnection.
42401e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
42411e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
42421e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42431e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42441e934351Sopenharmony_ci     * @since 11
42451e934351Sopenharmony_ci     */
42461e934351Sopenharmony_ci    /**
42471e934351Sopenharmony_ci     * Listens for message receiving events of the TLSSocketConnection.
42481e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
42491e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
42501e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42511e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42521e934351Sopenharmony_ci     * @crossplatform
42531e934351Sopenharmony_ci     * @since 12
42541e934351Sopenharmony_ci     */
42551e934351Sopenharmony_ci    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
42561e934351Sopenharmony_ci
42571e934351Sopenharmony_ci    /**
42581e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TLSSocketConnection.
42591e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
42601e934351Sopenharmony_ci     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of off.
42611e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42621e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42631e934351Sopenharmony_ci     * @since 10
42641e934351Sopenharmony_ci     */
42651e934351Sopenharmony_ci    /**
42661e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TLSSocketConnection.
42671e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
42681e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
42691e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42701e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42711e934351Sopenharmony_ci     * @since 11
42721e934351Sopenharmony_ci     */
42731e934351Sopenharmony_ci    /**
42741e934351Sopenharmony_ci     * Cancels listening for message receiving events of the TLSSocketConnection.
42751e934351Sopenharmony_ci     * @param { 'message' } type - Indicates Event name.
42761e934351Sopenharmony_ci     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
42771e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42781e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42791e934351Sopenharmony_ci     * @crossplatform
42801e934351Sopenharmony_ci     * @since 12
42811e934351Sopenharmony_ci     */
42821e934351Sopenharmony_ci    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
42831e934351Sopenharmony_ci
42841e934351Sopenharmony_ci    /**
42851e934351Sopenharmony_ci     * Listens for close events of the TLSSocketConnection.
42861e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
42871e934351Sopenharmony_ci     * @param { Callback<void> } callback - The callback of on.
42881e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42891e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
42901e934351Sopenharmony_ci     * @since 10
42911e934351Sopenharmony_ci     */
42921e934351Sopenharmony_ci    on(type: 'close', callback: Callback<void>): void;
42931e934351Sopenharmony_ci
42941e934351Sopenharmony_ci    /**
42951e934351Sopenharmony_ci     * Cancels listening for close events of the TLSSocketConnection.
42961e934351Sopenharmony_ci     * @param { 'close' } type - Indicates Event name.
42971e934351Sopenharmony_ci     * @param { Callback<void> } callback - The callback of off.
42981e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
42991e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
43001e934351Sopenharmony_ci     * @since 10
43011e934351Sopenharmony_ci     */
43021e934351Sopenharmony_ci    off(type: 'close', callback?: Callback<void>): void;
43031e934351Sopenharmony_ci
43041e934351Sopenharmony_ci    /**
43051e934351Sopenharmony_ci     * Listens for error events of the TLSSocketConnection.
43061e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
43071e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
43081e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
43091e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
43101e934351Sopenharmony_ci     * @since 10
43111e934351Sopenharmony_ci     */
43121e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
43131e934351Sopenharmony_ci
43141e934351Sopenharmony_ci    /**
43151e934351Sopenharmony_ci     * Cancels listening for error events of the TLSSocketConnection.
43161e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
43171e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
43181e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
43191e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
43201e934351Sopenharmony_ci     * @since 10
43211e934351Sopenharmony_ci     */
43221e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
43231e934351Sopenharmony_ci  }
43241e934351Sopenharmony_ci
43251e934351Sopenharmony_ci  /**
43261e934351Sopenharmony_ci   * Defines the socket connection information.
43271e934351Sopenharmony_ci   * @interface SocketMessageInfo
43281e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
43291e934351Sopenharmony_ci   * @crossplatform
43301e934351Sopenharmony_ci   * @since 11
43311e934351Sopenharmony_ci   */
43321e934351Sopenharmony_ci  export interface SocketMessageInfo {
43331e934351Sopenharmony_ci    /**
43341e934351Sopenharmony_ci     * Receive the message event.
43351e934351Sopenharmony_ci     * @type { ArrayBuffer }
43361e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
43371e934351Sopenharmony_ci     * @crossplatform
43381e934351Sopenharmony_ci     * @since 11
43391e934351Sopenharmony_ci     */
43401e934351Sopenharmony_ci    message: ArrayBuffer;
43411e934351Sopenharmony_ci    /**
43421e934351Sopenharmony_ci     * Socket connection information.
43431e934351Sopenharmony_ci     * @type { SocketRemoteInfo }
43441e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
43451e934351Sopenharmony_ci     * @crossplatform
43461e934351Sopenharmony_ci     * @since 11
43471e934351Sopenharmony_ci     */
43481e934351Sopenharmony_ci    remoteInfo: SocketRemoteInfo;
43491e934351Sopenharmony_ci  }
43501e934351Sopenharmony_ci
43511e934351Sopenharmony_ci  /**
43521e934351Sopenharmony_ci   * Defines a TLSSocketServer server connection.
43531e934351Sopenharmony_ci   * @interface TLSSocketServer
43541e934351Sopenharmony_ci   * @syscap SystemCapability.Communication.NetStack
43551e934351Sopenharmony_ci   * @since 10
43561e934351Sopenharmony_ci   */
43571e934351Sopenharmony_ci  export interface TLSSocketServer {
43581e934351Sopenharmony_ci    /**
43591e934351Sopenharmony_ci     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
43601e934351Sopenharmony_ci     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
43611e934351Sopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
43621e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
43631e934351Sopenharmony_ci     * @param { TLSConnectOptions } options - TLS connection options {@link TLSConnectOptions}.
43641e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of listen.
43651e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
43661e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
43671e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
43681e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
43691e934351Sopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
43701e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
43711e934351Sopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
43721e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
43731e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
43741e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
43751e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
43761e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
43771e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
43781e934351Sopenharmony_ci     * @since 10
43791e934351Sopenharmony_ci     */
43801e934351Sopenharmony_ci    listen(options: TLSConnectOptions, callback: AsyncCallback<void>): void;
43811e934351Sopenharmony_ci
43821e934351Sopenharmony_ci    /** 
43831e934351Sopenharmony_ci     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
43841e934351Sopenharmony_ci     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
43851e934351Sopenharmony_ci     * for accept processing and uses poll multiplex to process client connections.</p>
43861e934351Sopenharmony_ci     * @permission ohos.permission.INTERNET
43871e934351Sopenharmony_ci     * @param { TLSConnectOptions } options - TLS connection options {@link TLSConnectOptions}.
43881e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
43891e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
43901e934351Sopenharmony_ci     * @throws { BusinessError } 201 - Permission denied.
43911e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
43921e934351Sopenharmony_ci     * @throws { BusinessError } 2303109 - Bad file number.
43931e934351Sopenharmony_ci     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
43941e934351Sopenharmony_ci     * @throws { BusinessError } 2303198 - Address already in use.
43951e934351Sopenharmony_ci     * @throws { BusinessError } 2303199 - Cannot assign requested address.
43961e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
43971e934351Sopenharmony_ci     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
43981e934351Sopenharmony_ci     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
43991e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
44001e934351Sopenharmony_ci     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
44011e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44021e934351Sopenharmony_ci     * @since 10
44031e934351Sopenharmony_ci     */
44041e934351Sopenharmony_ci    listen(options: TLSConnectOptions): Promise<void>;
44051e934351Sopenharmony_ci
44061e934351Sopenharmony_ci    /**
44071e934351Sopenharmony_ci     * Obtains the status of the TLSSocketServer connection.
44081e934351Sopenharmony_ci     * @param { AsyncCallback<SocketStateBase> } callback - The callback of getState.
44091e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
44101e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
44111e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
44121e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44131e934351Sopenharmony_ci     * @since 10
44141e934351Sopenharmony_ci     */
44151e934351Sopenharmony_ci    getState(callback: AsyncCallback<SocketStateBase>): void;
44161e934351Sopenharmony_ci
44171e934351Sopenharmony_ci    /**
44181e934351Sopenharmony_ci     * Obtains the status of the TLSSocketServer connection.
44191e934351Sopenharmony_ci     * @returns { Promise<SocketStateBase> } The promise returned by the function.
44201e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
44211e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
44221e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44231e934351Sopenharmony_ci     * @since 10
44241e934351Sopenharmony_ci     */
44251e934351Sopenharmony_ci    getState(): Promise<SocketStateBase>;
44261e934351Sopenharmony_ci
44271e934351Sopenharmony_ci    /**
44281e934351Sopenharmony_ci     * Sets other attributes of the TLSSocketServer connection.
44291e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
44301e934351Sopenharmony_ci     * @param { AsyncCallback<void> } callback - The callback of setExtraOptions.
44311e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
44321e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
44331e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
44341e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44351e934351Sopenharmony_ci     * @since 10
44361e934351Sopenharmony_ci     */
44371e934351Sopenharmony_ci    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
44381e934351Sopenharmony_ci
44391e934351Sopenharmony_ci    /**
44401e934351Sopenharmony_ci     * Sets other attributes of the TLSSocketServer connection.
44411e934351Sopenharmony_ci     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
44421e934351Sopenharmony_ci     * @returns { Promise<void> } The promise returned by the function.
44431e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
44441e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
44451e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
44461e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44471e934351Sopenharmony_ci     * @since 10
44481e934351Sopenharmony_ci     */
44491e934351Sopenharmony_ci    setExtraOptions(options: TCPExtraOptions): Promise<void>;
44501e934351Sopenharmony_ci
44511e934351Sopenharmony_ci    /**
44521e934351Sopenharmony_ci     * Returns an object representing a local certificate.
44531e934351Sopenharmony_ci     * @param { AsyncCallback<X509CertRawData> } callback - The callback of getCertificate.
44541e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
44551e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
44561e934351Sopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
44571e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
44581e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44591e934351Sopenharmony_ci     * @since 10
44601e934351Sopenharmony_ci     */
44611e934351Sopenharmony_ci    getCertificate(callback: AsyncCallback<X509CertRawData>): void;
44621e934351Sopenharmony_ci
44631e934351Sopenharmony_ci    /**
44641e934351Sopenharmony_ci     * Returns an object representing a local certificate.
44651e934351Sopenharmony_ci     * @returns { Promise<X509CertRawData> } The promise returned by the function.
44661e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
44671e934351Sopenharmony_ci     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
44681e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
44691e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44701e934351Sopenharmony_ci     * @since 10
44711e934351Sopenharmony_ci     */
44721e934351Sopenharmony_ci    getCertificate(): Promise<X509CertRawData>;
44731e934351Sopenharmony_ci
44741e934351Sopenharmony_ci    /**
44751e934351Sopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
44761e934351Sopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
44771e934351Sopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
44781e934351Sopenharmony_ci     * @param { AsyncCallback<string> } callback - The callback of getProtocol.
44791e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
44801e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
44811e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
44821e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
44831e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44841e934351Sopenharmony_ci     * @since 10
44851e934351Sopenharmony_ci     */
44861e934351Sopenharmony_ci    getProtocol(callback: AsyncCallback<string>): void;
44871e934351Sopenharmony_ci
44881e934351Sopenharmony_ci    /**
44891e934351Sopenharmony_ci     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
44901e934351Sopenharmony_ci     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
44911e934351Sopenharmony_ci     * Server sockets or disconnected client sockets will return a value of null.
44921e934351Sopenharmony_ci     * @returns { Promise<string> } The promise returned by the function.
44931e934351Sopenharmony_ci     * @throws { BusinessError } 2303501 - SSL is null.
44941e934351Sopenharmony_ci     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
44951e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
44961e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
44971e934351Sopenharmony_ci     * @since 10
44981e934351Sopenharmony_ci     */
44991e934351Sopenharmony_ci    getProtocol(): Promise<string>;
45001e934351Sopenharmony_ci
45011e934351Sopenharmony_ci    /**
45021e934351Sopenharmony_ci     * Obtains the local address of the TLSSocketServer connection.
45031e934351Sopenharmony_ci     * @returns { Promise<NetAddress> } The promise returned by the function.
45041e934351Sopenharmony_ci     * @throws { BusinessError } 2300002 - System internal error.
45051e934351Sopenharmony_ci     * @throws { BusinessError } 2301009 - Bad file descriptor.
45061e934351Sopenharmony_ci     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
45071e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
45081e934351Sopenharmony_ci     * @since 12
45091e934351Sopenharmony_ci     */
45101e934351Sopenharmony_ci    getLocalAddress(): Promise<NetAddress>;
45111e934351Sopenharmony_ci
45121e934351Sopenharmony_ci    /**
45131e934351Sopenharmony_ci     * Listens for connect events of the TLSSocketServer connection.
45141e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
45151e934351Sopenharmony_ci     * @param { Callback<TLSSocketConnection> } callback - The callback of on.
45161e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
45171e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
45181e934351Sopenharmony_ci     * @since 10
45191e934351Sopenharmony_ci     */
45201e934351Sopenharmony_ci    on(type: 'connect', callback: Callback<TLSSocketConnection>): void;
45211e934351Sopenharmony_ci
45221e934351Sopenharmony_ci    /**
45231e934351Sopenharmony_ci     * Cancels listening for connect events of the TLSSocketServer connection.
45241e934351Sopenharmony_ci     * @param { 'connect' } type - Indicates Event name.
45251e934351Sopenharmony_ci     * @param { Callback<TLSSocketConnection> } callback - The callback of off.
45261e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
45271e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
45281e934351Sopenharmony_ci     * @since 10
45291e934351Sopenharmony_ci     */
45301e934351Sopenharmony_ci    off(type: 'connect', callback?: Callback<TLSSocketConnection>): void;
45311e934351Sopenharmony_ci
45321e934351Sopenharmony_ci    /**
45331e934351Sopenharmony_ci     * Listens for error events of the TLSSocketServer connection.
45341e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
45351e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of on.
45361e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
45371e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
45381e934351Sopenharmony_ci     * @since 10
45391e934351Sopenharmony_ci     */
45401e934351Sopenharmony_ci    on(type: 'error', callback: ErrorCallback): void;
45411e934351Sopenharmony_ci
45421e934351Sopenharmony_ci    /**
45431e934351Sopenharmony_ci     * Cancels listening for error events of the TLSSocketServer connection.
45441e934351Sopenharmony_ci     * @param { 'error' } type - Indicates Event name.
45451e934351Sopenharmony_ci     * @param { ErrorCallback } callback - The callback of off.
45461e934351Sopenharmony_ci     * @throws { BusinessError } 401 - Parameter error.
45471e934351Sopenharmony_ci     * @syscap SystemCapability.Communication.NetStack
45481e934351Sopenharmony_ci     * @since 10
45491e934351Sopenharmony_ci     */
45501e934351Sopenharmony_ci    off(type: 'error', callback?: ErrorCallback): void;
45511e934351Sopenharmony_ci  }
45521e934351Sopenharmony_ci}
45531e934351Sopenharmony_ci
45541e934351Sopenharmony_ciexport default socket;
4555