• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit NetworkKit
19 */
20
21import type { AsyncCallback, Callback, ErrorCallback } from './@ohos.base';
22import connection from "./@ohos.net.connection";
23import type cert from './@ohos.security.cert';
24
25/**
26 * Provides TCP and UDP Socket APIs.
27 * @namespace socket
28 * @syscap SystemCapability.Communication.NetStack
29 * @since 7
30 */
31/**
32 * Provides TCP and UDP Socket APIs.
33 * @namespace socket
34 * @syscap SystemCapability.Communication.NetStack
35 * @crossplatform
36 * @since 10
37 */
38declare namespace socket {
39  export import NetAddress = connection.NetAddress;
40  /**
41   * Deposit certificate
42   * @syscap SystemCapability.Communication.NetStack
43   * @since 9
44   */
45  /**
46   * Deposit certificate
47   * @typedef { cert.EncodingBlob }
48   * @syscap SystemCapability.Communication.NetStack
49   * @crossplatform
50   * @since 10
51   */
52  export type X509CertRawData = cert.EncodingBlob;
53
54  /**
55   * Creates a UDPSocket object.
56   * @returns { UDPSocket } the UDPSocket of the constructUDPSocketInstance.
57   * @syscap SystemCapability.Communication.NetStack
58   * @since 7
59   */
60  /**
61   * Creates a UDPSocket object.
62   * @returns { UDPSocket } the UDPSocket of the constructUDPSocketInstance.
63   * @syscap SystemCapability.Communication.NetStack
64   * @crossplatform
65   * @since 10
66   */
67  function constructUDPSocketInstance(): UDPSocket;
68
69  /**
70   * Creates a MulticastSocket object.
71   * @returns { MulticastSocket } the MulticastSocket of the constructMulticastSocketInstance.
72   * @syscap SystemCapability.Communication.NetStack
73   * @since 11
74   */
75  /**
76   * Creates a MulticastSocket object.
77   * @returns { MulticastSocket } the MulticastSocket of the constructMulticastSocketInstance.
78   * @syscap SystemCapability.Communication.NetStack
79   * @crossplatform
80   * @since 12
81   */
82  function constructMulticastSocketInstance(): MulticastSocket;
83
84  /**
85   * Creates a TCPSocket object.
86   * @returns { TCPSocket } the TCPSocket of the constructTCPSocketInstance.
87   * @syscap SystemCapability.Communication.NetStack
88   * @since 7
89   */
90  /**
91   * Creates a TCPSocket object.
92   * @returns { TCPSocket } the TCPSocket of the constructTCPSocketInstance.
93   * @syscap SystemCapability.Communication.NetStack
94   * @crossplatform
95   * @since 10
96   */
97  function constructTCPSocketInstance(): TCPSocket;
98
99  /**
100   * Creates a TLSSocket object.
101   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
102   * @syscap SystemCapability.Communication.NetStack
103   * @since 9
104   */
105  /**
106   * Creates a TLSSocket object.
107   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
108   * @syscap SystemCapability.Communication.NetStack
109   * @crossplatform
110   * @since 10
111   */
112  function constructTLSSocketInstance(): TLSSocket;
113
114  /**
115   * Creates a TLSSocket object with a TCPSocket object.
116   * @param { TCPSocket } tcpSocket - Parameter for creating a TLSSocket object.
117   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
118   * @throws { BusinessError } 401 - Parameter error.
119   * @throws { BusinessError } 2300002 - System internal error.
120   * @throws { BusinessError } 2303601 - Invalid socket FD.
121   * @throws { BusinessError } 2303602 - Socket is not connected.
122   * @syscap SystemCapability.Communication.NetStack
123   * @since 12
124   */
125  function constructTLSSocketInstance(tcpSocket: TCPSocket): TLSSocket;
126
127  /**
128   * Creates a TCPSocketServer object.
129   * @returns { TCPSocketServer } the TCPSocketServer of the constructTCPSocketServerInstance.
130   * @syscap SystemCapability.Communication.NetStack
131   * @since 10
132   */
133  function constructTCPSocketServerInstance(): TCPSocketServer;
134
135  /**
136   * Creates a TLSSocketServer object.
137   * @returns { TLSSocketServer } the TLSSocketServer of the constructTLSSocketServerInstance.
138   * @syscap SystemCapability.Communication.NetStack
139   * @since 10
140   */
141  function constructTLSSocketServerInstance(): TLSSocketServer;
142
143  /**
144   * Creates a LocalSocket object.
145   * @returns { LocalSocket } the LocalSocket of the constructLocalSocketInstance.
146   * @syscap SystemCapability.Communication.NetStack
147   * @since 11
148   */
149  /**
150   * Creates a LocalSocket object.
151   * @returns { LocalSocket } the LocalSocket of the constructLocalSocketInstance.
152   * @syscap SystemCapability.Communication.NetStack
153   * @crossplatform
154   * @since 12
155   */
156  function constructLocalSocketInstance(): LocalSocket;
157
158  /**
159   * Creates a LocalSocketServer object.
160   * @returns { LocalSocketServer } the LocalSocketServer of the constructLocalSocketServerInstance.
161   * @syscap SystemCapability.Communication.NetStack
162   * @since 11
163   */
164  /**
165   * Creates a LocalSocketServer object.
166   * @returns { LocalSocketServer } the LocalSocketServer of the constructLocalSocketServerInstance.
167   * @syscap SystemCapability.Communication.NetStack
168   * @crossplatform
169   * @since 12
170   */
171  function constructLocalSocketServerInstance(): LocalSocketServer;
172
173  /**
174   * Defines the parameters for sending data over the UDPSocket connection.
175   * @interface UDPSendOptions
176   * @syscap SystemCapability.Communication.NetStack
177   * @since 7
178   */
179  /**
180   * Defines the parameters for sending data over the UDPSocket connection.
181   * @interface UDPSendOptions
182   * @syscap SystemCapability.Communication.NetStack
183   * @crossplatform
184   * @since 10
185   */
186  export interface UDPSendOptions {
187    /**
188     * Data to send.
189     * @type {string | ArrayBuffer}
190     * @syscap SystemCapability.Communication.NetStack
191     * @since 7
192     */
193    /**
194     * Data to send.
195     * @type {string | ArrayBuffer}
196     * @syscap SystemCapability.Communication.NetStack
197     * @crossplatform
198     * @since 10
199     */
200    data: string | ArrayBuffer;
201
202    /**
203     * Destination address.
204     * @type {NetAddress}
205     * @syscap SystemCapability.Communication.NetStack
206     * @since 7
207     */
208    /**
209     * Destination address.
210     * @type {NetAddress}
211     * @syscap SystemCapability.Communication.NetStack
212     * @crossplatform
213     * @since 10
214     */
215    address: NetAddress;
216
217    /**
218     * Destination proxy.
219     * @type {ProxyOptions}
220     * @syscap SystemCapability.Communication.NetStack
221     * @crossplatform
222     * @since 16
223     */
224    proxy?: ProxyOptions;
225  }
226
227  /**
228   * Deposit proxy types
229   * @syscap SystemCapability.Communication.NetStack
230   * @crossplatform
231   * @since 16
232   */
233  export enum ProxyTypes {
234    NONE = 0,
235    SOCKS5 = 1,
236  }
237
238  /**
239   * @interface Socks5Proxy
240   * @syscap SystemCapability.Communication.NetStack
241   * @crossplatform
242   * @since 16
243   */
244  export interface ProxyOptions {
245    type: ProxyTypes;
246    address: NetAddress;
247    username?: string;
248    password?: string;
249  }
250
251  /**
252   * @interface ExtraOptionsBase
253   * @syscap SystemCapability.Communication.NetStack
254   * @since 7
255   */
256  /**
257   * @interface ExtraOptionsBase
258   * @syscap SystemCapability.Communication.NetStack
259   * @crossplatform
260   * @since 10
261   */
262  export interface ExtraOptionsBase {
263    /**
264     * Size of the receive buffer, in MBS.
265     * @type {?number}
266     * @syscap SystemCapability.Communication.NetStack
267     * @since 7
268     */
269    /**
270     * Size of the receive buffer, in MBS.
271     * @type {?number}
272     * @syscap SystemCapability.Communication.NetStack
273     * @crossplatform
274     * @since 10
275     */
276    receiveBufferSize?: number;
277
278    /**
279     * Size of the send buffer, in MBS.
280     * @type {?number}
281     * @syscap SystemCapability.Communication.NetStack
282     * @since 7
283     */
284    /**
285     * Size of the send buffer, in MBS.
286     * @type {?number}
287     * @syscap SystemCapability.Communication.NetStack
288     * @crossplatform
289     * @since 10
290     */
291    sendBufferSize?: number;
292
293    /**
294     * Whether to reuse addresses. The default value is false.
295     * @type {?boolean}
296     * @syscap SystemCapability.Communication.NetStack
297     * @since 7
298     */
299    /**
300     * Whether to reuse addresses. The default value is false.
301     * @type {?boolean}
302     * @syscap SystemCapability.Communication.NetStack
303     * @crossplatform
304     * @since 10
305     */
306    reuseAddress?: boolean;
307
308    /**
309     * Timeout duration of the UDPSocket connection, in milliseconds.
310     * @type {?number}
311     * @syscap SystemCapability.Communication.NetStack
312     * @since 7
313     */
314    /**
315     * Timeout duration of the UDPSocket connection, in milliseconds.
316     * @type {?number}
317     * @syscap SystemCapability.Communication.NetStack
318     * @crossplatform
319     * @since 10
320     */
321    socketTimeout?: number;
322  }
323
324  /**
325   * Defines other properties of the UDPSocket connection.
326   * @interface UDPExtraOptions
327   * @syscap SystemCapability.Communication.NetStack
328   * @since 7
329   */
330  /**
331   * Defines other properties of the UDPSocket connection.
332   * @interface UDPExtraOptions
333   * @syscap SystemCapability.Communication.NetStack
334   * @crossplatform
335   * @since 10
336   */
337  export interface UDPExtraOptions extends ExtraOptionsBase {
338    /**
339     * Whether to send broadcast messages. The default value is false.
340     * @type {?boolean}
341     * @syscap SystemCapability.Communication.NetStack
342     * @since 7
343     */
344    /**
345     * Whether to send broadcast messages. The default value is false.
346     * @type {?boolean}
347     * @syscap SystemCapability.Communication.NetStack
348     * @crossplatform
349     * @since 10
350     */
351    broadcast?: boolean;
352  }
353
354  /**
355   * Defines the status of the socket connection.
356   * @interface SocketStateBase
357   * @syscap SystemCapability.Communication.NetStack
358   * @since 7
359   */
360  /**
361   * Defines the status of the socket connection.
362   * @interface SocketStateBase
363   * @syscap SystemCapability.Communication.NetStack
364   * @crossplatform
365   * @since 10
366   */
367  export interface SocketStateBase {
368    /**
369     * Whether the connection is in the bound state.
370     * @type {boolean}
371     * @syscap SystemCapability.Communication.NetStack
372     * @since 7
373     */
374    /**
375     * Whether the connection is in the bound state.
376     * @type {boolean}
377     * @syscap SystemCapability.Communication.NetStack
378     * @crossplatform
379     * @since 10
380     */
381    isBound: boolean;
382
383    /**
384     * Whether the connection is in the closed state.
385     * @type {boolean}
386     * @syscap SystemCapability.Communication.NetStack
387     * @since 7
388     */
389    /**
390     * Whether the connection is in the closed state.
391     * @type {boolean}
392     * @syscap SystemCapability.Communication.NetStack
393     * @crossplatform
394     * @since 10
395     */
396    isClose: boolean;
397
398    /**
399     * Whether the connection is in the connected state.
400     * @type {boolean}
401     * @syscap SystemCapability.Communication.NetStack
402     * @since 7
403     */
404    /**
405     * Whether the connection is in the connected state.
406     * @type {boolean}
407     * @syscap SystemCapability.Communication.NetStack
408     * @crossplatform
409     * @since 10
410     */
411    isConnected: boolean;
412  }
413
414  /**
415   * Defines information about the socket connection.
416   * @interface SocketRemoteInfo
417   * @syscap SystemCapability.Communication.NetStack
418   * @since 7
419   */
420  /**
421   * Defines information about the socket connection.
422   * @interface SocketRemoteInfo
423   * @syscap SystemCapability.Communication.NetStack
424   * @crossplatform
425   * @since 10
426   */
427  export interface SocketRemoteInfo {
428    /**
429     * Bound IP address.
430     * @type {string}
431     * @syscap SystemCapability.Communication.NetStack
432     * @since 7
433     */
434    /**
435     * Bound IP address.
436     * @type {string}
437     * @syscap SystemCapability.Communication.NetStack
438     * @crossplatform
439     * @since 10
440     */
441    address: string;
442
443    /**
444     * Network protocol type. The options are as follows: IPv4, IPv6.
445     * @type {'IPv4' | 'IPv6'}
446     * @syscap SystemCapability.Communication.NetStack
447     * @since 7
448     */
449    /**
450     * Network protocol type. The options are as follows: IPv4, IPv6.
451     * @type {'IPv4' | 'IPv6'}
452     * @syscap SystemCapability.Communication.NetStack
453     * @crossplatform
454     * @since 10
455     */
456    family: 'IPv4' | 'IPv6';
457
458    /**
459     * Port number. The value ranges from 0 to 65535.
460     * @type {number}
461     * @syscap SystemCapability.Communication.NetStack
462     * @since 7
463     */
464    /**
465     * Port number. The value ranges from 0 to 65535.
466     * @type {number}
467     * @syscap SystemCapability.Communication.NetStack
468     * @crossplatform
469     * @since 10
470     */
471    port: number;
472
473    /**
474     * Length of the server response message, in bytes.
475     * @type {number}
476     * @syscap SystemCapability.Communication.NetStack
477     * @since 7
478     */
479    /**
480     * Length of the server response message, in bytes.
481     * @type {number}
482     * @syscap SystemCapability.Communication.NetStack
483     * @crossplatform
484     * @since 10
485     */
486    size: number;
487  }
488
489  /**
490   * Defines the local socket connection information.
491   * @interface LocalSocketMessageInfo
492   * @syscap SystemCapability.Communication.NetStack
493   * @since 11
494   */
495  /**
496   * Defines the local socket connection information.
497   * @interface LocalSocketMessageInfo
498   * @syscap SystemCapability.Communication.NetStack
499   * @crossplatform
500   * @since 12
501   */
502  export interface LocalSocketMessageInfo {
503    /**
504     * Message data.
505     * @type {ArrayBuffer}
506     * @syscap SystemCapability.Communication.NetStack
507     * @since 11
508     */
509    /**
510     * Message data.
511     * @type {ArrayBuffer}
512     * @syscap SystemCapability.Communication.NetStack
513     * @crossplatform
514     * @since 12
515     */
516    message: ArrayBuffer;
517
518    /**
519     * Bound local socket address.
520     * @type {string}
521     * @syscap SystemCapability.Communication.NetStack
522     * @since 11
523     */
524    /**
525     * Bound local socket address.
526     * @type {string}
527     * @syscap SystemCapability.Communication.NetStack
528     * @crossplatform
529     * @since 12
530     */
531    address: string;
532
533    /**
534     * Length of the message, in bytes.
535     * @type {number}
536     * @syscap SystemCapability.Communication.NetStack
537     * @since 11
538     */
539    /**
540     * Length of the message, in bytes.
541     * @type {number}
542     * @syscap SystemCapability.Communication.NetStack
543     * @crossplatform
544     * @since 12
545     */
546    size: number;
547  }
548
549  /**
550   * Defines a local address.
551   * @interface LocalAddress
552   * @syscap SystemCapability.Communication.NetStack
553   * @since 11
554   */
555  /**
556   * Defines a local address.
557   * @interface LocalAddress
558   * @syscap SystemCapability.Communication.NetStack
559   * @crossplatform
560   * @since 12
561   */
562  export interface LocalAddress {
563    /**
564     * LocalAddress address.
565     * @type {string}
566     * @syscap SystemCapability.Communication.NetStack
567     * @since 11
568     */
569    /**
570     * LocalAddress address.
571     * @type {string}
572     * @syscap SystemCapability.Communication.NetStack
573     * @crossplatform
574     * @since 12
575     */
576    address: string;
577  }
578
579  /**
580   * Defines LocalSocket connection parameters.
581   * @interface LocalConnectOptions
582   * @syscap SystemCapability.Communication.NetStack
583   * @since 11
584   */
585  /**
586   * Defines LocalSocket connection parameters.
587   * @interface LocalConnectOptions
588   * @syscap SystemCapability.Communication.NetStack
589   * @crossplatform
590   * @since 12
591   */
592  export interface LocalConnectOptions {
593    /**
594     * Bound Local address.
595     * @type {LocalAddress}
596     * @syscap SystemCapability.Communication.NetStack
597     * @since 11
598     */
599    /**
600     * Bound Local address.
601     * @type {LocalAddress}
602     * @syscap SystemCapability.Communication.NetStack
603     * @crossplatform
604     * @since 12
605     */
606    address: LocalAddress;
607
608    /**
609     * Timeout duration of the LocalSocket connection, in milliseconds.
610     * @type {?number}
611     * @syscap SystemCapability.Communication.NetStack
612     * @since 11
613     */
614    /**
615     * Timeout duration of the LocalSocket connection, in milliseconds.
616     * @type {?number}
617     * @syscap SystemCapability.Communication.NetStack
618     * @crossplatform
619     * @since 12
620     */
621    timeout?: number;
622  }
623
624  /**
625   * Defines the parameters for sending data over the LocalSocket connection.
626   * @interface LocalSendOptions
627   * @syscap SystemCapability.Communication.NetStack
628   * @since 11
629   */
630  /**
631   * Defines the parameters for sending data over the LocalSocket connection.
632   * @interface LocalSendOptions
633   * @syscap SystemCapability.Communication.NetStack
634   * @crossplatform
635   * @since 12
636   */
637  export interface LocalSendOptions {
638    /**
639     * Data to send.
640     * @type {string | ArrayBuffer}
641     * @syscap SystemCapability.Communication.NetStack
642     * @since 11
643     */
644    /**
645     * Data to send.
646     * @type {string | ArrayBuffer}
647     * @syscap SystemCapability.Communication.NetStack
648     * @crossplatform
649     * @since 12
650     */
651    data: string | ArrayBuffer;
652
653    /**
654     * Character encoding format.
655     * @type {?string}
656     * @syscap SystemCapability.Communication.NetStack
657     * @since 11
658     */
659    /**
660     * Character encoding format.
661     * @type {?string}
662     * @syscap SystemCapability.Communication.NetStack
663     * @crossplatform
664     * @since 12
665     */
666    encoding?: string;
667  }
668
669  /**
670   * Defines a UDPSocket connection.
671   * @interface UDPSocket
672   * @syscap SystemCapability.Communication.NetStack
673   * @since 7
674   */
675  /**
676   * Defines a UDPSocket connection.
677   * @interface UDPSocket
678   * @syscap SystemCapability.Communication.NetStack
679   * @crossplatform
680   * @since 10
681   */
682  export interface UDPSocket {
683    /**
684     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
685     * @permission ohos.permission.INTERNET
686     * @param { NetAddress } address - Destination address. {@link NetAddress}
687     * @param { AsyncCallback<void> } callback - the callback of bind.
688     * @throws { BusinessError } 401 - Parameter error.
689     * @throws { BusinessError } 201 - Permission denied.
690     * @syscap SystemCapability.Communication.NetStack
691     * @since 7
692     */
693    /**
694     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
695     * @permission ohos.permission.INTERNET
696     * @param { NetAddress } address - Destination address. {@link NetAddress}
697     * @param { AsyncCallback<void> } callback - the callback of bind.
698     * @throws { BusinessError } 401 - Parameter error.
699     * @throws { BusinessError } 201 - Permission denied.
700     * @syscap SystemCapability.Communication.NetStack
701     * @crossplatform
702     * @since 10
703     */
704    bind(address: NetAddress, callback: AsyncCallback<void>): void;
705
706    /**
707     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
708     * @permission ohos.permission.INTERNET
709     * @param { NetAddress } address - Destination address. {@link NetAddress}
710     * @returns { Promise<void> } The promise returned by the function.
711     * @throws { BusinessError } 401 - Parameter error.
712     * @throws { BusinessError } 201 - Permission denied.
713     * @syscap SystemCapability.Communication.NetStack
714     * @since 7
715     */
716    /**
717     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
718     * @permission ohos.permission.INTERNET
719     * @param { NetAddress } address - Destination address. {@link NetAddress}
720     * @returns { Promise<void> } The promise returned by the function.
721     * @throws { BusinessError } 401 - Parameter error.
722     * @throws { BusinessError } 201 - Permission denied.
723     * @syscap SystemCapability.Communication.NetStack
724     * @crossplatform
725     * @since 10
726     */
727    bind(address: NetAddress): Promise<void>;
728
729    /**
730     * Obtains the local address of a UDPSocket connection.
731     * @returns { Promise<NetAddress> } The promise returned by the function.
732     * @throws { BusinessError } 2300002 - System internal error.
733     * @throws { BusinessError } 2301009 - Bad file descriptor.
734     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
735     * @syscap SystemCapability.Communication.NetStack
736     * @since 12
737     */
738    getLocalAddress(): Promise<NetAddress>;
739
740    /**
741     * Sends data over a UDPSocket connection.
742     * @permission ohos.permission.INTERNET
743     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
744     * @param { AsyncCallback<void> } callback - the callback of send.
745     * @throws { BusinessError } 401 - Parameter error.
746     * @throws { BusinessError } 201 - Permission denied.
747     * @syscap SystemCapability.Communication.NetStack
748     * @since 7
749     */
750    /**
751     * Sends data over a UDPSocket connection.
752     * @permission ohos.permission.INTERNET
753     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
754     * @param { AsyncCallback<void> } callback - the callback of send.
755     * @throws { BusinessError } 401 - Parameter error.
756     * @throws { BusinessError } 201 - Permission denied.
757     * @syscap SystemCapability.Communication.NetStack
758     * @crossplatform
759     * @since 10
760     */
761    send(options: UDPSendOptions, callback: AsyncCallback<void>): void;
762
763    /**
764     * Sends data over a UDPSocket connection.
765     * @permission ohos.permission.INTERNET
766     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
767     * @returns { Promise<void> } The promise returned by the function.
768     * @throws { BusinessError } 401 - Parameter error.
769     * @throws { BusinessError } 201 - Permission denied.
770     * @syscap SystemCapability.Communication.NetStack
771     * @since 7
772     */
773    /**
774     * Sends data over a UDPSocket connection.
775     * @permission ohos.permission.INTERNET
776     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
777     * @returns { Promise<void> } The promise returned by the function.
778     * @throws { BusinessError } 401 - Parameter error.
779     * @throws { BusinessError } 201 - Permission denied.
780     * @syscap SystemCapability.Communication.NetStack
781     * @crossplatform
782     * @since 10
783     */
784    send(options: UDPSendOptions): Promise<void>;
785
786    /**
787     * Closes a UDPSocket connection.
788     * @permission ohos.permission.INTERNET
789     * @param { AsyncCallback<void> } callback - the callback of close.
790     * @throws { BusinessError } 201 - Permission denied.
791     * @syscap SystemCapability.Communication.NetStack
792     * @since 7
793     */
794    /**
795     * Closes a UDPSocket connection.
796     * @permission ohos.permission.INTERNET
797     * @param { AsyncCallback<void> } callback - the callback of close.
798     * @throws { BusinessError } 201 - Permission denied.
799     * @syscap SystemCapability.Communication.NetStack
800     * @crossplatform
801     * @since 10
802     */
803    close(callback: AsyncCallback<void>): void;
804
805    /**
806     * Closes a UDPSocket connection.
807     * @permission ohos.permission.INTERNET
808     * @returns { Promise<void> } The promise returned by the function.
809     * @throws { BusinessError } 201 - Permission denied.
810     * @syscap SystemCapability.Communication.NetStack
811     * @since 7
812     */
813    /**
814     * Closes a UDPSocket connection.
815     * @permission ohos.permission.INTERNET
816     * @returns { Promise<void> } The promise returned by the function.
817     * @throws { BusinessError } 201 - Permission denied.
818     * @syscap SystemCapability.Communication.NetStack
819     * @crossplatform
820     * @since 10
821     */
822    close(): Promise<void>;
823
824    /**
825     * Obtains the status of the UDPSocket connection.
826     * @permission ohos.permission.INTERNET
827     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}.
828     * @throws { BusinessError } 201 - Permission denied.
829     * @syscap SystemCapability.Communication.NetStack
830     * @since 7
831     */
832    /**
833     * Obtains the status of the UDPSocket connection.
834     * @permission ohos.permission.INTERNET
835     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}.
836     * @throws { BusinessError } 201 - Permission denied.
837     * @syscap SystemCapability.Communication.NetStack
838     * @crossplatform
839     * @since 10
840     */
841    getState(callback: AsyncCallback<SocketStateBase>): void;
842
843    /**
844     * Obtains the status of the UDPSocket connection.
845     * @permission ohos.permission.INTERNET
846     * @returns { Promise<SocketStateBase> } The promise returned by the function.
847     * @throws { BusinessError } 201 - Permission denied.
848     * @syscap SystemCapability.Communication.NetStack
849     * @since 7
850     */
851    /**
852     * Obtains the status of the UDPSocket connection.
853     * @permission ohos.permission.INTERNET
854     * @returns { Promise<SocketStateBase> } The promise returned by the function.
855     * @throws { BusinessError } 201 - Permission denied.
856     * @syscap SystemCapability.Communication.NetStack
857     * @crossplatform
858     * @since 10
859     */
860    getState(): Promise<SocketStateBase>;
861
862    /**
863     * Sets other attributes of the UDPSocket connection.
864     * @permission ohos.permission.INTERNET
865     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
866     * @param { AsyncCallback<void> }callback - the callback of setExtraOptions.
867     * @throws { BusinessError } 401 - Parameter error.
868     * @throws { BusinessError } 201 - Permission denied.
869     * @syscap SystemCapability.Communication.NetStack
870     * @since 7
871     */
872    /**
873     * Sets other attributes of the UDPSocket connection.
874     * @permission ohos.permission.INTERNET
875     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
876     * @param { AsyncCallback<void> }callback - the callback of setExtraOptions.
877     * @throws { BusinessError } 401 - Parameter error.
878     * @throws { BusinessError } 201 - Permission denied.
879     * @syscap SystemCapability.Communication.NetStack
880     * @crossplatform
881     * @since 10
882     */
883    setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback<void>): void;
884
885    /**
886     * Sets other attributes of the UDPSocket connection.
887     * @permission ohos.permission.INTERNET
888     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
889     * @returns { Promise<void> } The promise returned by the function.
890     * @throws { BusinessError } 401 - Parameter error.
891     * @throws { BusinessError } 201 - Permission denied.
892     * @syscap SystemCapability.Communication.NetStack
893     * @since 7
894     */
895    /**
896     * Sets other attributes of the UDPSocket connection.
897     * @permission ohos.permission.INTERNET
898     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
899     * @returns { Promise<void> } The promise returned by the function.
900     * @throws { BusinessError } 401 - Parameter error.
901     * @throws { BusinessError } 201 - Permission denied.
902     * @syscap SystemCapability.Communication.NetStack
903     * @crossplatform
904     * @since 10
905     */
906    setExtraOptions(options: UDPExtraOptions): Promise<void>;
907
908    /**
909     * Listens for message receiving events of the UDPSocket connection.
910     * @param { 'message' } type - Indicates Event name.
911     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
912     * @syscap SystemCapability.Communication.NetStack
913     * @since 7
914     */
915    /**
916     * Listens for message receiving events of the UDPSocket connection.
917     * @param { 'message' } type - Indicates Event name.
918     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
919     * @syscap SystemCapability.Communication.NetStack
920     * @crossplatform
921     * @since 10
922     */
923    /**
924     * Listens for message receiving events of the UDPSocket connection.
925     * @param { 'message' } type - Indicates Event name.
926     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
927     * @syscap SystemCapability.Communication.NetStack
928     * @crossplatform
929     * @since 11
930     */
931    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
932
933    /**
934     * Cancels listening for message receiving events of the UDPSocket connection.
935     * @param { 'message' } type - Indicates Event name.
936     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
937     * @syscap SystemCapability.Communication.NetStack
938     * @since 7
939     */
940    /**
941     * Cancels listening for message receiving events of the UDPSocket connection.
942     * @param { 'message' } type - Indicates Event name.
943     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
944     * @syscap SystemCapability.Communication.NetStack
945     * @crossplatform
946     * @since 10
947     */
948    /**
949     * Cancels listening for message receiving events of the UDPSocket connection.
950     * @param { 'message' } type - Indicates Event name.
951     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
952     * @syscap SystemCapability.Communication.NetStack
953     * @crossplatform
954     * @since 11
955     */
956    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
957
958    /**
959     * Listens for data packet message events or close events of the UDPSocket connection.
960     * @param { 'listening' | 'close' } type - Indicates Event name.
961     * @param { Callback<void> } callback - the callback used to return the result.
962     * @syscap SystemCapability.Communication.NetStack
963     * @since 7
964     */
965    /**
966     * Listens for data packet message events or close events of the UDPSocket connection.
967     * @param { 'listening' | 'close' } type - Indicates Event name.
968     * @param { Callback<void> } callback - the callback used to return the result.
969     * @syscap SystemCapability.Communication.NetStack
970     * @crossplatform
971     * @since 10
972     */
973    on(type: 'listening' | 'close', callback: Callback<void>): void;
974
975    /**
976     * Cancels listening for data packet message events or close events of the UDPSocket connection.
977     * @param { 'listening' | 'close' } type - Indicates Event name.
978     * @param { Callback<void> } callback - the callback used to return the result.
979     * @syscap SystemCapability.Communication.NetStack
980     * @since 7
981     */
982    /**
983     * Cancels listening for data packet message events or close events of the UDPSocket connection.
984     * @param { 'listening' | 'close' } type - Indicates Event name.
985     * @param { Callback<void> } callback - the callback used to return the result.
986     * @syscap SystemCapability.Communication.NetStack
987     * @crossplatform
988     * @since 10
989     */
990    off(type: 'listening' | 'close', callback?: Callback<void>): void;
991
992    /**
993     * Listens for error events of the UDPSocket connection.
994     * @param { 'error' } type - Indicates Event name.
995     * @param { ErrorCallback } callback - the callback used to return the result.
996     * @syscap SystemCapability.Communication.NetStack
997     * @since 7
998     */
999    /**
1000     * Listens for error events of the UDPSocket connection.
1001     * @param { 'error' } type - Indicates Event name.
1002     * @param { ErrorCallback } callback - the callback used to return the result.
1003     * @syscap SystemCapability.Communication.NetStack
1004     * @crossplatform
1005     * @since 10
1006     */
1007    on(type: 'error', callback: ErrorCallback): void;
1008
1009    /**
1010     * Cancels listening for error events of the UDPSocket connection.
1011     * @param { 'error' } type - Indicates Event name.
1012     * @param { ErrorCallback } callback - the callback used to return the result.
1013     * @syscap SystemCapability.Communication.NetStack
1014     * @since 7
1015     */
1016    /**
1017     * Cancels listening for error events of the UDPSocket connection.
1018     * @param { 'error' } type - Indicates Event name.
1019     * @param { ErrorCallback } callback - the callback used to return the result.
1020     * @syscap SystemCapability.Communication.NetStack
1021     * @crossplatform
1022     * @since 10
1023     */
1024    off(type: 'error', callback?: ErrorCallback): void;
1025  }
1026
1027  /**
1028   * Defines a UDP MulticastSocket connection.
1029   * @interface MulticastSocket
1030   * @syscap SystemCapability.Communication.NetStack
1031   * @since 11
1032   */
1033  /**
1034   * Defines a UDP MulticastSocket connection.
1035   * @interface MulticastSocket
1036   * @syscap SystemCapability.Communication.NetStack
1037   * @crossplatform
1038   * @since 12
1039   */
1040  export interface MulticastSocket extends UDPSocket {
1041    /**
1042     * Add the socket to the multicast group.
1043     * @permission ohos.permission.INTERNET
1044     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
1045     * @param { AsyncCallback<void> } callback - The callback of addMembership.
1046     * @throws { BusinessError } 201 - Permission denied.
1047     * @throws { BusinessError } 401 - Parameter error.
1048     * @throws { BusinessError } 2301022 - Invalid argument.
1049     * @throws { BusinessError } 2301088 - Not a socket.
1050     * @throws { BusinessError } 2301098 - Address in use.
1051     * @syscap SystemCapability.Communication.NetStack
1052     * @since 11
1053     */
1054    /**
1055     * Add the socket to the multicast group.
1056     * @permission ohos.permission.INTERNET
1057     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
1058     * @param { AsyncCallback<void> } callback - The callback of addMembership.
1059     * @throws { BusinessError } 201 - Permission denied.
1060     * @throws { BusinessError } 401 - Parameter error.
1061     * @throws { BusinessError } 2301022 - Invalid argument.
1062     * @throws { BusinessError } 2301088 - Not a socket.
1063     * @throws { BusinessError } 2301098 - Address in use.
1064     * @syscap SystemCapability.Communication.NetStack
1065     * @crossplatform
1066     * @since 12
1067     */
1068    addMembership(multicastAddress: NetAddress, callback: AsyncCallback<void>): void;
1069
1070    /**
1071     * Add the socket to the multicast group.
1072     * @permission ohos.permission.INTERNET
1073     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
1074     * @returns { Promise<void> } The promise returned by the function.
1075     * @throws { BusinessError } 201 - Permission denied.
1076     * @throws { BusinessError } 401 - Parameter error.
1077     * @throws { BusinessError } 2301088 - Not a socket.
1078     * @throws { BusinessError } 2301098 - Address in use.
1079     * @syscap SystemCapability.Communication.NetStack
1080     * @since 11
1081     */
1082    /**
1083     * Add the socket to the multicast group.
1084     * @permission ohos.permission.INTERNET
1085     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
1086     * @returns { Promise<void> } The promise returned by the function.
1087     * @throws { BusinessError } 201 - Permission denied.
1088     * @throws { BusinessError } 401 - Parameter error.
1089     * @throws { BusinessError } 2301088 - Not a socket.
1090     * @throws { BusinessError } 2301098 - Address in use.
1091     * @syscap SystemCapability.Communication.NetStack
1092     * @crossplatform
1093     * @since 12
1094     */
1095    addMembership(multicastAddress: NetAddress): Promise<void>;
1096
1097    /**
1098     * Drop the socket from the multicast group.
1099     * @permission ohos.permission.INTERNET
1100     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
1101     * @param { AsyncCallback<void> } callback - The callback of dropMembership.
1102     * @throws { BusinessError } 201 - Permission denied.
1103     * @throws { BusinessError } 401 - Parameter error.
1104     * @throws { BusinessError } 2301088 - Not a socket.
1105     * @throws { BusinessError } 2301098 - Address in use.
1106     * @syscap SystemCapability.Communication.NetStack
1107     * @since 11
1108     */
1109    /**
1110     * Drop the socket from the multicast group.
1111     * @permission ohos.permission.INTERNET
1112     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
1113     * @param { AsyncCallback<void> } callback - The callback of dropMembership.
1114     * @throws { BusinessError } 201 - Permission denied.
1115     * @throws { BusinessError } 401 - Parameter error.
1116     * @throws { BusinessError } 2301088 - Not a socket.
1117     * @throws { BusinessError } 2301098 - Address in use.
1118     * @syscap SystemCapability.Communication.NetStack
1119     * @crossplatform
1120     * @since 12
1121     */
1122    dropMembership(multicastAddress: NetAddress, callback: AsyncCallback<void>): void;
1123
1124    /**
1125     * Drop the socket from the multicast group.
1126     * @permission ohos.permission.INTERNET
1127     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
1128     * @returns { Promise<void> } The promise returned by the function.
1129     * @throws { BusinessError } 201 - Permission denied.
1130     * @throws { BusinessError } 401 - Parameter error.
1131     * @throws { BusinessError } 2301088 - Not a socket.
1132     * @throws { BusinessError } 2301098 - Address in use.
1133     * @syscap SystemCapability.Communication.NetStack
1134     * @since 11
1135     */
1136    /**
1137     * Drop the socket from the multicast group.
1138     * @permission ohos.permission.INTERNET
1139     * @param { NetAddress } multicastAddress - Multicast address information. {@link NetAddress}.
1140     * @returns { Promise<void> } The promise returned by the function.
1141     * @throws { BusinessError } 201 - Permission denied.
1142     * @throws { BusinessError } 401 - Parameter error.
1143     * @throws { BusinessError } 2301088 - Not a socket.
1144     * @throws { BusinessError } 2301098 - Address in use.
1145     * @syscap SystemCapability.Communication.NetStack
1146     * @crossplatform
1147     * @since 12
1148     */
1149    dropMembership(multicastAddress: NetAddress): Promise<void>;
1150
1151    /**
1152     * Set the TTL value for socket multicast packets.
1153     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
1154     * @param { AsyncCallback<void> } callback - The callback of setMulticastTTL.
1155     * @throws { BusinessError } 401 - Parameter error.
1156     * @throws { BusinessError } 2301022 - Invalid argument.
1157     * @throws { BusinessError } 2301088 - Not a socket.
1158     * @syscap SystemCapability.Communication.NetStack
1159     * @since 11
1160     */
1161    /**
1162     * Set the TTL value for socket multicast packets.
1163     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
1164     * @param { AsyncCallback<void> } callback - The callback of setMulticastTTL.
1165     * @throws { BusinessError } 401 - Parameter error.
1166     * @throws { BusinessError } 2301022 - Invalid argument.
1167     * @throws { BusinessError } 2301088 - Not a socket.
1168     * @syscap SystemCapability.Communication.NetStack
1169     * @crossplatform
1170     * @since 12
1171     */
1172    setMulticastTTL(ttl: number, callback: AsyncCallback<void>): void;
1173
1174    /**
1175     * Set the TTL value for socket multicast packet.
1176     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
1177     * @returns { Promise<void> } The promise returned by the function.
1178     * @throws { BusinessError } 401 - Parameter error.
1179     * @throws { BusinessError } 2301022 - Invalid argument.
1180     * @throws { BusinessError } 2301088 - Not a socket.
1181     * @syscap SystemCapability.Communication.NetStack
1182     * @since 11
1183     */
1184    /**
1185     * Set the TTL value for socket multicast packet.
1186     * @param { number } ttl - The TTL value to set. Valid range is typically 0 to 255.
1187     * @returns { Promise<void> } The promise returned by the function.
1188     * @throws { BusinessError } 401 - Parameter error.
1189     * @throws { BusinessError } 2301022 - Invalid argument.
1190     * @throws { BusinessError } 2301088 - Not a socket.
1191     * @syscap SystemCapability.Communication.NetStack
1192     * @crossplatform
1193     * @since 12
1194     */
1195    setMulticastTTL(ttl: number): Promise<void>;
1196
1197    /**
1198     * Get the TTL value of socket multicast packet.
1199     * @param { AsyncCallback<number> } callback - The callback of getMulticastTTL.
1200     * @throws { BusinessError } 401 - Parameter error.
1201     * @throws { BusinessError } 2301088 - Not a socket.
1202     * @syscap SystemCapability.Communication.NetStack
1203     * @since 11
1204     */
1205    /**
1206     * Get the TTL value of socket multicast packet.
1207     * @param { AsyncCallback<number> } callback - The callback of getMulticastTTL.
1208     * @throws { BusinessError } 401 - Parameter error.
1209     * @throws { BusinessError } 2301088 - Not a socket.
1210     * @syscap SystemCapability.Communication.NetStack
1211     * @crossplatform
1212     * @since 12
1213     */
1214    getMulticastTTL(callback: AsyncCallback<number>): void;
1215
1216    /**
1217     * Get the TTL value of socket multicast packet.
1218     * @returns { Promise<number> } The promise returned by the function.
1219     * @throws { BusinessError } 401 - Parameter error.
1220     * @throws { BusinessError } 2301088 - Not a socket.
1221     * @syscap SystemCapability.Communication.NetStack
1222     * @since 11
1223     */
1224    /**
1225     * Get the TTL value of socket multicast packet.
1226     * @returns { Promise<number> } The promise returned by the function.
1227     * @throws { BusinessError } 401 - Parameter error.
1228     * @throws { BusinessError } 2301088 - Not a socket.
1229     * @syscap SystemCapability.Communication.NetStack
1230     * @crossplatform
1231     * @since 12
1232     */
1233    getMulticastTTL(): Promise<number>;
1234
1235    /**
1236     * Set the loopback mode for the socket.
1237     * @param { boolean } flag - Whether to enable loopback mode.
1238     * @param { AsyncCallback<void> } callback - The callback of setLoopbackMode.
1239     * @throws { BusinessError } 401 - Parameter error.
1240     * @throws { BusinessError } 2301088 - Not a socket.
1241     * @syscap SystemCapability.Communication.NetStack
1242     * @since 11
1243     */
1244    /**
1245     * Set the loopback mode for the socket.
1246     * @param { boolean } flag - Whether to enable loopback mode.
1247     * @param { AsyncCallback<void> } callback - The callback of setLoopbackMode.
1248     * @throws { BusinessError } 401 - Parameter error.
1249     * @throws { BusinessError } 2301088 - Not a socket.
1250     * @syscap SystemCapability.Communication.NetStack
1251     * @crossplatform
1252     * @since 12
1253     */
1254    setLoopbackMode(flag: boolean, callback: AsyncCallback<void>): void;
1255
1256    /**
1257     * Set the loopback mode for the socket.
1258     * @param { boolean } flag - Whether to enable loopback mode.
1259     * @returns { Promise<void> } The promise returned by the function.
1260     * @throws { BusinessError } 401 - Parameter error.
1261     * @throws { BusinessError } 2301088 - Not a socket.
1262     * @syscap SystemCapability.Communication.NetStack
1263     * @since 11
1264     */
1265    /**
1266     * Set the loopback mode for the socket.
1267     * @param { boolean } flag - Whether to enable loopback mode.
1268     * @returns { Promise<void> } The promise returned by the function.
1269     * @throws { BusinessError } 401 - Parameter error.
1270     * @throws { BusinessError } 2301088 - Not a socket.
1271     * @syscap SystemCapability.Communication.NetStack
1272     * @crossplatform
1273     * @since 12
1274     */
1275    setLoopbackMode(flag: boolean): Promise<void>;
1276
1277    /**
1278     * Get the loopback mode of the socket.
1279     * @param { AsyncCallback<boolean> } callback - The callback of getLoopbackMode.
1280     * @throws { BusinessError } 401 - Parameter error.
1281     * @throws { BusinessError } 2301088 - Not a socket.
1282     * @syscap SystemCapability.Communication.NetStack
1283     * @since 11
1284     */
1285    /**
1286     * Get the loopback mode of the socket.
1287     * @param { AsyncCallback<boolean> } callback - The callback of getLoopbackMode.
1288     * @throws { BusinessError } 401 - Parameter error.
1289     * @throws { BusinessError } 2301088 - Not a socket.
1290     * @syscap SystemCapability.Communication.NetStack
1291     * @crossplatform
1292     * @since 12
1293     */
1294    getLoopbackMode(callback: AsyncCallback<boolean>): void;
1295
1296    /**
1297     * Get the loopback mode of the socket.
1298     * @returns { Promise<boolean> } The promise returned by the function.
1299     * @throws { BusinessError } 401 - Parameter error.
1300     * @throws { BusinessError } 2301088 - Not a socket.
1301     * @syscap SystemCapability.Communication.NetStack
1302     * @since 11
1303     */
1304    /**
1305     * Get the loopback mode of the socket.
1306     * @returns { Promise<boolean> } The promise returned by the function.
1307     * @throws { BusinessError } 401 - Parameter error.
1308     * @throws { BusinessError } 2301088 - Not a socket.
1309     * @syscap SystemCapability.Communication.NetStack
1310     * @crossplatform
1311     * @since 12
1312     */
1313    getLoopbackMode(): Promise<boolean>;
1314  }
1315
1316  /**
1317   * Defines a LocalSocket connection.
1318   * @interface LocalSocket
1319   * @syscap SystemCapability.Communication.NetStack
1320   * @since 11
1321   */
1322  /**
1323   * Defines a LocalSocket connection.
1324   * @interface LocalSocket
1325   * @syscap SystemCapability.Communication.NetStack
1326   * @crossplatform
1327   * @since 12
1328   */
1329  export interface LocalSocket {
1330    /**
1331     * Binds the Local address.
1332     * @param { LocalAddress } address - Destination address. {@link LocalAddress}
1333     * @returns { Promise<void> } The promise returned by the function.
1334     * @throws { BusinessError } 401 - Parameter error.
1335     * @throws { BusinessError } 2301013 - Insufficient permissions.
1336     * @throws { BusinessError } 2301022 - Invalid argument.
1337     * @throws { BusinessError } 2301098 - Address already in use.
1338     * @syscap SystemCapability.Communication.NetStack
1339     * @since 11
1340     */
1341    /**
1342     * Binds the Local address.
1343     * @param { LocalAddress } address - Destination address. {@link LocalAddress}
1344     * @returns { Promise<void> } The promise returned by the function.
1345     * @throws { BusinessError } 401 - Parameter error.
1346     * @throws { BusinessError } 2301013 - Insufficient permissions.
1347     * @throws { BusinessError } 2301022 - Invalid argument.
1348     * @throws { BusinessError } 2301098 - Address already in use.
1349     * @syscap SystemCapability.Communication.NetStack
1350     * @crossplatform
1351     * @since 12
1352     */
1353    bind(address: LocalAddress): Promise<void>;
1354
1355    /**
1356     * Sets up a connection to the specified Local address .
1357     * @param { LocalConnectOptions } options - Optional parameters {@link LocalConnectOptions}.
1358     * @returns { Promise<void> } The promise returned by the function.
1359     * @throws { BusinessError } 401 - Parameter error.
1360     * @throws { BusinessError } 2301013 - Insufficient permissions.
1361     * @throws { BusinessError } 2301022 - Invalid argument.
1362     * @throws { BusinessError } 2301111 - Connection refused.
1363     * @throws { BusinessError } 2301099 - Cannot assign requested address.
1364     * @syscap SystemCapability.Communication.NetStack
1365     * @since 11
1366     */
1367    /**
1368     * Sets up a connection to the specified Local address .
1369     * @param { LocalConnectOptions } options - Optional parameters {@link LocalConnectOptions}.
1370     * @returns { Promise<void> } The promise returned by the function.
1371     * @throws { BusinessError } 401 - Parameter error.
1372     * @throws { BusinessError } 2301013 - Insufficient permissions.
1373     * @throws { BusinessError } 2301022 - Invalid argument.
1374     * @throws { BusinessError } 2301111 - Connection refused.
1375     * @throws { BusinessError } 2301099 - Cannot assign requested address.
1376     * @syscap SystemCapability.Communication.NetStack
1377     * @crossplatform
1378     * @since 12
1379     */
1380    connect(options: LocalConnectOptions): Promise<void>;
1381
1382    /**
1383     * Sends data over a LocalSocket connection.
1384     * @param { LocalSendOptions } options - Optional parameters {@link LocalSendOptions}.
1385     * @returns { Promise<void> } The promise returned by the function.
1386     * @throws { BusinessError } 401 - Parameter error.
1387     * @throws { BusinessError } 2301011 - Operation would block.
1388     * @syscap SystemCapability.Communication.NetStack
1389     * @since 11
1390     */
1391    /**
1392     * Sends data over a LocalSocket connection.
1393     * @param { LocalSendOptions } options - Optional parameters {@link LocalSendOptions}.
1394     * @returns { Promise<void> } The promise returned by the function.
1395     * @throws { BusinessError } 401 - Parameter error.
1396     * @throws { BusinessError } 2301011 - Operation would block.
1397     * @syscap SystemCapability.Communication.NetStack
1398     * @crossplatform
1399     * @since 12
1400     */
1401    send(options: LocalSendOptions): Promise<void>;
1402
1403    /**
1404     * Closes a LocalSocket connection.
1405     * @returns { Promise<void> } The promise returned by the function.
1406     * @throws { BusinessError } 2301009 - Bad file descriptor.
1407     * @syscap SystemCapability.Communication.NetStack
1408     * @since 11
1409     */
1410    /**
1411     * Closes a LocalSocket connection.
1412     * @returns { Promise<void> } The promise returned by the function.
1413     * @throws { BusinessError } 2301009 - Bad file descriptor.
1414     * @syscap SystemCapability.Communication.NetStack
1415     * @crossplatform
1416     * @since 12
1417     */
1418    close(): Promise<void>;
1419
1420    /**
1421     * Obtains the status of the LocalSocket connection.
1422     * @returns { Promise<SocketStateBase> } The promise returned by the function.
1423     * @syscap SystemCapability.Communication.NetStack
1424     * @since 11
1425     */
1426    /**
1427     * Obtains the status of the LocalSocket connection.
1428     * @returns { Promise<SocketStateBase> } The promise returned by the function.
1429     * @syscap SystemCapability.Communication.NetStack
1430     * @crossplatform
1431     * @since 12
1432     */
1433    getState(): Promise<SocketStateBase>;
1434
1435    /**
1436     * Obtains the file descriptor of the LocalSocket connection.
1437     * @returns { Promise<number> } The promise returns the file descriptor of the LocalSocket connection.
1438     * @syscap SystemCapability.Communication.NetStack
1439     * @since 11
1440     */
1441    /**
1442     * Obtains the file descriptor of the LocalSocket connection.
1443     * @returns { Promise<number> } The promise returns the file descriptor of the LocalSocket connection.
1444     * @syscap SystemCapability.Communication.NetStack
1445     * @crossplatform
1446     * @since 12
1447     */
1448    getSocketFd(): Promise<number>;
1449
1450    /**
1451     * Sets other attributes of the LocalSocket connection.
1452     * @param { ExtraOptionsBase } options - Optional parameters {@link ExtraOptionsBase}.
1453     * @returns { Promise<void> } The promise returned by the function.
1454     * @throws { BusinessError } 401 - Parameter error.
1455     * @throws { BusinessError } 2301009 - Bad file descriptor.
1456     * @syscap SystemCapability.Communication.NetStack
1457     * @since 11
1458     */
1459    /**
1460     * Sets other attributes of the LocalSocket connection.
1461     * @param { ExtraOptionsBase } options - Optional parameters {@link ExtraOptionsBase}.
1462     * @returns { Promise<void> } The promise returned by the function.
1463     * @throws { BusinessError } 401 - Parameter error.
1464     * @throws { BusinessError } 2301009 - Bad file descriptor.
1465     * @syscap SystemCapability.Communication.NetStack
1466     * @crossplatform
1467     * @since 12
1468     */
1469    setExtraOptions(options: ExtraOptionsBase): Promise<void>;
1470
1471    /**
1472     * Gets other attributes of the LocalSocket connection.
1473     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
1474     * @throws { BusinessError } 2301009 - Bad file descriptor.
1475     * @syscap SystemCapability.Communication.NetStack
1476     * @since 11
1477     */
1478    /**
1479     * Gets other attributes of the LocalSocket connection.
1480     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
1481     * @throws { BusinessError } 2301009 - Bad file descriptor.
1482     * @syscap SystemCapability.Communication.NetStack
1483     * @crossplatform
1484     * @since 12
1485     */
1486    getExtraOptions(): Promise<ExtraOptionsBase>;
1487
1488    /**
1489     * Obtains the local address of a LocalSocket connection.
1490     * @returns { Promise<string> } The promise returned by the function.
1491     * @throws { BusinessError } 2300002 - System internal error.
1492     * @throws { BusinessError } 2301009 - Bad file descriptor.
1493     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1494     * @syscap SystemCapability.Communication.NetStack
1495     * @since 12
1496     */
1497    getLocalAddress(): Promise<string>;
1498
1499    /**
1500     * Listens for message receiving events of the LocalSocket connection.
1501     * @param { 'message' } type Indicates Event name.
1502     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
1503     * @throws { BusinessError } 401 - Parameter error.
1504     * @syscap SystemCapability.Communication.NetStack
1505     * @since 11
1506     */
1507    /**
1508     * Listens for message receiving events of the LocalSocket connection.
1509     * @param { 'message' } type Indicates Event name.
1510     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
1511     * @throws { BusinessError } 401 - Parameter error.
1512     * @syscap SystemCapability.Communication.NetStack
1513     * @crossplatform
1514     * @since 12
1515     */
1516    on(type: 'message', callback: Callback<LocalSocketMessageInfo>): void;
1517
1518    /**
1519     * Cancels listening for message receiving events of the LocalSocket connection.
1520     * @param { 'message' } type Indicates Event name.
1521     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
1522     * @throws { BusinessError } 401 - Parameter error.
1523     * @syscap SystemCapability.Communication.NetStack
1524     * @since 11
1525     */
1526    /**
1527     * Cancels listening for message receiving events of the LocalSocket connection.
1528     * @param { 'message' } type Indicates Event name.
1529     * @param { Callback<LocalSocketMessageInfo> } callback - the callback used to return the result.
1530     * @throws { BusinessError } 401 - Parameter error.
1531     * @syscap SystemCapability.Communication.NetStack
1532     * @crossplatform
1533     * @since 12
1534     */
1535    off(type: 'message', callback?: Callback<LocalSocketMessageInfo>): void;
1536
1537    /**
1538     * Listens for connection events of the LocalSocket connection.
1539     * @param { 'connect' } type - Indicates Event name.
1540     * @param { Callback<void> } callback - the callback used to return the result.
1541     * @throws { BusinessError } 401 - Parameter error.
1542     * @syscap SystemCapability.Communication.NetStack
1543     * @since 11
1544     */
1545    /**
1546     * Listens for connection events of the LocalSocket connection.
1547     * @param { 'connect' } type - Indicates Event name.
1548     * @param { Callback<void> } callback - the callback used to return the result.
1549     * @throws { BusinessError } 401 - Parameter error.
1550     * @syscap SystemCapability.Communication.NetStack
1551     * @crossplatform
1552     * @since 12
1553     */
1554    on(type: 'connect', callback: Callback<void>): void;
1555
1556    /**
1557     * Cancels listening for connection events of the LocalSocket connection.
1558     * @param { 'connect' } type - Indicates Event name.
1559     * @param { Callback<void> } callback - the callback used to return the result.
1560     * @throws { BusinessError } 401 - Parameter error.
1561     * @syscap SystemCapability.Communication.NetStack
1562     * @since 11
1563     */
1564    /**
1565     * Cancels listening for connection events of the LocalSocket connection.
1566     * @param { 'connect' } type - Indicates Event name.
1567     * @param { Callback<void> } callback - the callback used to return the result.
1568     * @throws { BusinessError } 401 - Parameter error.
1569     * @syscap SystemCapability.Communication.NetStack
1570     * @crossplatform
1571     * @since 12
1572     */
1573    off(type: 'connect', callback?: Callback<void>): void;
1574
1575    /**
1576     * Listens for close events of the LocalSocket connection.
1577     * @param { 'close' } type - Indicates Event name.
1578     * @param { Callback<void> } callback - the callback used to return the result.
1579     * @throws { BusinessError } 401 - Parameter error.
1580     * @syscap SystemCapability.Communication.NetStack
1581     * @since 11
1582     */
1583    /**
1584     * Listens for close events of the LocalSocket connection.
1585     * @param { 'close' } type - Indicates Event name.
1586     * @param { Callback<void> } callback - the callback used to return the result.
1587     * @throws { BusinessError } 401 - Parameter error.
1588     * @syscap SystemCapability.Communication.NetStack
1589     * @crossplatform
1590     * @since 12
1591     */
1592    on(type: 'close', callback: Callback<void>): void;
1593
1594    /**
1595     * Cancels listening for close events of the LocalSocket connection.
1596     * @param { 'close' } type - Indicates Event name.
1597     * @param { Callback<void> } callback - the callback used to return the result.
1598     * @throws { BusinessError } 401 - Parameter error.
1599     * @syscap SystemCapability.Communication.NetStack
1600     * @since 11
1601     */
1602    /**
1603     * Cancels listening for close events of the LocalSocket connection.
1604     * @param { 'close' } type - Indicates Event name.
1605     * @param { Callback<void> } callback - the callback used to return the result.
1606     * @throws { BusinessError } 401 - Parameter error.
1607     * @syscap SystemCapability.Communication.NetStack
1608     * @crossplatform
1609     * @since 12
1610     */
1611    off(type: 'close', callback?: Callback<void>): void;
1612
1613    /**
1614     * Listens for error events of the LocalSocket connection.
1615     * @param { 'error' } type - Indicates Event name.
1616     * @param { ErrorCallback } callback - the callback used to return the result.
1617     * @throws { BusinessError } 401 - Parameter error.
1618     * @syscap SystemCapability.Communication.NetStack
1619     * @since 11
1620     */
1621    /**
1622     * Listens for error events of the LocalSocket connection.
1623     * @param { 'error' } type - Indicates Event name.
1624     * @param { ErrorCallback } callback - the callback used to return the result.
1625     * @throws { BusinessError } 401 - Parameter error.
1626     * @syscap SystemCapability.Communication.NetStack
1627     * @crossplatform
1628     * @since 12
1629     */
1630    on(type: 'error', callback: ErrorCallback): void;
1631
1632    /**
1633     * Cancels listening for error events of the LocalSocket connection.
1634     * @param { 'error' } type - Indicates Event name.
1635     * @param { ErrorCallback } callback - the callback used to return the result.
1636     * @throws { BusinessError } 401 - Parameter error.
1637     * @syscap SystemCapability.Communication.NetStack
1638     * @since 11
1639     */
1640    /**
1641     * Cancels listening for error events of the LocalSocket connection.
1642     * @param { 'error' } type - Indicates Event name.
1643     * @param { ErrorCallback } callback - the callback used to return the result.
1644     * @throws { BusinessError } 401 - Parameter error.
1645     * @syscap SystemCapability.Communication.NetStack
1646     * @crossplatform
1647     * @since 12
1648     */
1649    off(type: 'error', callback?: ErrorCallback): void;
1650  }
1651
1652  /**
1653   * Defines the connection of the LocalSocket client and server.
1654   * @interface LocalSocketConnection
1655   * @syscap SystemCapability.Communication.NetStack
1656   * @since 11
1657   */
1658  /**
1659   * Defines the connection of the LocalSocket client and server.
1660   * @interface LocalSocketConnection
1661   * @syscap SystemCapability.Communication.NetStack
1662   * @crossplatform
1663   * @since 12
1664   */
1665  export interface LocalSocketConnection {
1666    /**
1667     * The id of a client connects to the LocalSocketServer.
1668     * @type {number}
1669     * @syscap SystemCapability.Communication.NetStack
1670     * @since 11
1671     */
1672    /**
1673     * The id of a client connects to the LocalSocketServer.
1674     * @type {number}
1675     * @syscap SystemCapability.Communication.NetStack
1676     * @crossplatform
1677     * @since 12
1678     */
1679    clientId: number;
1680
1681    /**
1682     * Sends data over a LocalSocketServer connection to client.
1683     * @param { LocalSendOptions } options - Parameters for sending data {@link LocalSendOptions}.
1684     * @returns { Promise<void> } The promise returned by the function.
1685     * @throws { BusinessError } 401 - Parameter error.
1686     * @throws { BusinessError } 2301011 - Operation would block.
1687     * @syscap SystemCapability.Communication.NetStack
1688     * @since 11
1689     */
1690    /**
1691     * Sends data over a LocalSocketServer connection to client.
1692     * @param { LocalSendOptions } options - Parameters for sending data {@link LocalSendOptions}.
1693     * @returns { Promise<void> } The promise returned by the function.
1694     * @throws { BusinessError } 401 - Parameter error.
1695     * @throws { BusinessError } 2301011 - Operation would block.
1696     * @syscap SystemCapability.Communication.NetStack
1697     * @crossplatform
1698     * @since 12
1699     */
1700    send(options: LocalSendOptions): Promise<void>;
1701
1702    /**
1703     * Closes a LocalSocket client connection.
1704     * @returns { Promise<void> } The promise returned by the function.
1705     * @throws { BusinessError } 2301009 - Bad file descriptor.
1706     * @syscap SystemCapability.Communication.NetStack
1707     * @since 11
1708     */
1709    /**
1710     * Closes a LocalSocket client connection.
1711     * @returns { Promise<void> } The promise returned by the function.
1712     * @throws { BusinessError } 2301009 - Bad file descriptor.
1713     * @syscap SystemCapability.Communication.NetStack
1714     * @crossplatform
1715     * @since 12
1716     */
1717    close(): Promise<void>;
1718
1719    /**
1720     * Obtains the local address of a LocalSocket client connection.
1721     * @returns { Promise<string> } The promise returned by the function.
1722     * @throws { BusinessError } 2300002 - System internal error.
1723     * @throws { BusinessError } 2301009 - Bad file descriptor.
1724     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1725     * @syscap SystemCapability.Communication.NetStack
1726     * @since 12
1727     */
1728    getLocalAddress(): Promise<string>;
1729
1730    /**
1731     * Listens for message receiving events of the LocalSocketConnection.
1732     * @param { 'message' } type - Indicates Event name.
1733     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of on.
1734     * @throws { BusinessError } 401 - Parameter error.
1735     * @syscap SystemCapability.Communication.NetStack
1736     * @since 11
1737     */
1738    /**
1739     * Listens for message receiving events of the LocalSocketConnection.
1740     * @param { 'message' } type - Indicates Event name.
1741     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of on.
1742     * @throws { BusinessError } 401 - Parameter error.
1743     * @syscap SystemCapability.Communication.NetStack
1744     * @crossplatform
1745     * @since 12
1746     */
1747    on(type: 'message', callback: Callback<LocalSocketMessageInfo>): void;
1748
1749    /**
1750     * Cancels listening for message receiving events of the LocalSocketConnection.
1751     * @param { 'message' } type - Indicates Event name.
1752     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of off.
1753     * @throws { BusinessError } 401 - Parameter error.
1754     * @syscap SystemCapability.Communication.NetStack
1755     * @since 11
1756     */
1757    /**
1758     * Cancels listening for message receiving events of the LocalSocketConnection.
1759     * @param { 'message' } type - Indicates Event name.
1760     * @param { Callback<LocalSocketMessageInfo> } callback - The callback of off.
1761     * @throws { BusinessError } 401 - Parameter error.
1762     * @syscap SystemCapability.Communication.NetStack
1763     * @crossplatform
1764     * @since 12
1765     */
1766    off(type: 'message', callback?: Callback<LocalSocketMessageInfo>): void;
1767
1768    /**
1769     * Listens for close events of the LocalSocketConnection.
1770     * @param { 'close' } type - Indicates Event name.
1771     * @param { Callback<void> } callback - The callback of on.
1772     * @throws { BusinessError } 401 - Parameter error.
1773     * @syscap SystemCapability.Communication.NetStack
1774     * @since 11
1775     */
1776    /**
1777     * Listens for close events of the LocalSocketConnection.
1778     * @param { 'close' } type - Indicates Event name.
1779     * @param { Callback<void> } callback - The callback of on.
1780     * @throws { BusinessError } 401 - Parameter error.
1781     * @syscap SystemCapability.Communication.NetStack
1782     * @crossplatform
1783     * @since 12
1784     */
1785    on(type: 'close', callback: Callback<void>): void;
1786
1787    /**
1788     * Cancels listening for close events of the LocalSocketConnection.
1789     * @param { 'close' } type - Indicates Event name.
1790     * @param { Callback<void> } callback - The callback of off.
1791     * @throws { BusinessError } 401 - Parameter error.
1792     * @syscap SystemCapability.Communication.NetStack
1793     * @since 11
1794     */
1795    /**
1796     * Cancels listening for close events of the LocalSocketConnection.
1797     * @param { 'close' } type - Indicates Event name.
1798     * @param { Callback<void> } callback - The callback of off.
1799     * @throws { BusinessError } 401 - Parameter error.
1800     * @syscap SystemCapability.Communication.NetStack
1801     * @crossplatform
1802     * @since 12
1803     */
1804    off(type: 'close', callback?: Callback<void>): void;
1805
1806    /**
1807     * Listens for error events of the LocalSocketConnection.
1808     * @param { 'error' } type - Indicates Event name.
1809     * @param { ErrorCallback } callback - The callback of on.
1810     * @throws { BusinessError } 401 - Parameter error.
1811     * @syscap SystemCapability.Communication.NetStack
1812     * @since 11
1813     */
1814    /**
1815     * Listens for error events of the LocalSocketConnection.
1816     * @param { 'error' } type - Indicates Event name.
1817     * @param { ErrorCallback } callback - The callback of on.
1818     * @throws { BusinessError } 401 - Parameter error.
1819     * @syscap SystemCapability.Communication.NetStack
1820     * @crossplatform
1821     * @since 12
1822     */
1823    on(type: 'error', callback: ErrorCallback): void;
1824
1825    /**
1826     * Cancels listening for error events of the LocalSocketConnection.
1827     * @param { 'error' } type - Indicates Event name.
1828     * @param { ErrorCallback } callback - The callback of off.
1829     * @throws { BusinessError } 401 - Parameter error.
1830     * @syscap SystemCapability.Communication.NetStack
1831     * @since 11
1832     */
1833    /**
1834     * Cancels listening for error events of the LocalSocketConnection.
1835     * @param { 'error' } type - Indicates Event name.
1836     * @param { ErrorCallback } callback - The callback of off.
1837     * @throws { BusinessError } 401 - Parameter error.
1838     * @syscap SystemCapability.Communication.NetStack
1839     * @crossplatform
1840     * @since 12
1841     */
1842    off(type: 'error', callback?: ErrorCallback): void;
1843  }
1844
1845  /**
1846   * Defines a LocalSocket server connection.
1847   * @interface LocalSocketServer
1848   * @syscap SystemCapability.Communication.NetStack
1849   * @since 11
1850   */
1851  /**
1852   * Defines a LocalSocket server connection.
1853   * @interface LocalSocketServer
1854   * @syscap SystemCapability.Communication.NetStack
1855   * @crossplatform
1856   * @since 12
1857   */
1858  export interface LocalSocketServer {
1859    /**
1860     * Binds the Local address.
1861     * <p>Listens for a LocalSocket connection to be made to this socket and accepts it. This interface uses multiple threads
1862     * for accept processing and uses poll multiplex to process client connections.</p>
1863     * @param { LocalAddress } address - Network address information {@link LocalAddress}.
1864     * @returns { Promise<void> } The promise returned by the function.
1865     * @throws { BusinessError } 401 - Parameter error.
1866     * @throws { BusinessError } 2303109 - Bad file number.
1867     * @throws { BusinessError } 2301013 - Insufficient permissions.
1868     * @throws { BusinessError } 2301022 - Invalid argument.
1869     * @throws { BusinessError } 2301098 - Address already in use.
1870     * @syscap SystemCapability.Communication.NetStack
1871     * @since 11
1872     */
1873    /**
1874     * Binds the Local address.
1875     * <p>Listens for a LocalSocket connection to be made to this socket and accepts it. This interface uses multiple threads
1876     * for accept processing and uses poll multiplex to process client connections.</p>
1877     * @param { LocalAddress } address - Network address information {@link LocalAddress}.
1878     * @returns { Promise<void> } The promise returned by the function.
1879     * @throws { BusinessError } 401 - Parameter error.
1880     * @throws { BusinessError } 2303109 - Bad file number.
1881     * @throws { BusinessError } 2301013 - Insufficient permissions.
1882     * @throws { BusinessError } 2301022 - Invalid argument.
1883     * @throws { BusinessError } 2301098 - Address already in use.
1884     * @syscap SystemCapability.Communication.NetStack
1885     * @crossplatform
1886     * @since 12
1887     */
1888    listen(address: LocalAddress): Promise<void>;
1889
1890    /**
1891     * Obtains the status of the LocalSocketServer connection.
1892     * @returns { Promise<SocketStateBase> } The promise returned by the function.
1893     * @syscap SystemCapability.Communication.NetStack
1894     * @since 11
1895     */
1896    /**
1897     * Obtains the status of the LocalSocketServer connection.
1898     * @returns { Promise<SocketStateBase> } The promise returned by the function.
1899     * @syscap SystemCapability.Communication.NetStack
1900     * @crossplatform
1901     * @since 12
1902     */
1903    getState(): Promise<SocketStateBase>;
1904
1905    /**
1906     * Sets other attributes of the LocalSocketServer connection.
1907     * @param { ExtraOptionsBase } options - Parameters of the attributes {@link ExtraOptionsBase}.
1908     * @returns { Promise<void> } The promise returned by the function.
1909     * @throws { BusinessError } 401 - Parameter error.
1910     * @throws { BusinessError } 2301009 - Bad file descriptor.
1911     * @syscap SystemCapability.Communication.NetStack
1912     * @since 11
1913     */
1914    /**
1915     * Sets other attributes of the LocalSocketServer connection.
1916     * @param { ExtraOptionsBase } options - Parameters of the attributes {@link ExtraOptionsBase}.
1917     * @returns { Promise<void> } The promise returned by the function.
1918     * @throws { BusinessError } 401 - Parameter error.
1919     * @throws { BusinessError } 2301009 - Bad file descriptor.
1920     * @syscap SystemCapability.Communication.NetStack
1921     * @crossplatform
1922     * @since 12
1923     */
1924    setExtraOptions(options: ExtraOptionsBase): Promise<void>;
1925
1926    /**
1927     * Gets other attributes of the LocalSocket connection.
1928     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
1929     * @throws { BusinessError } 401 - Parameter error.
1930     * @syscap SystemCapability.Communication.NetStack
1931     * @since 11
1932     */
1933    /**
1934     * Gets other attributes of the LocalSocket connection.
1935     * @returns { Promise<ExtraOptionsBase> } The promise returned by the function.
1936     * @throws { BusinessError } 401 - Parameter error.
1937     * @syscap SystemCapability.Communication.NetStack
1938     * @crossplatform
1939     * @since 12
1940     */
1941    getExtraOptions(): Promise<ExtraOptionsBase>;
1942
1943    /**
1944     * Obtains the local address of the LocalSocketServer connection.
1945     * @returns { Promise<string> } The promise returned by the function.
1946     * @throws { BusinessError } 2300002 - System internal error.
1947     * @throws { BusinessError } 2301009 - Bad file descriptor.
1948     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1949     * @syscap SystemCapability.Communication.NetStack
1950     * @since 12
1951     */
1952    getLocalAddress(): Promise<string>;
1953
1954    /**
1955     * Listens for connect events of the LocalSocketServer connection.
1956     * @param { 'connect' } type - Indicates Event name.
1957     * @param { Callback<LocalSocketConnection> } callback - The callback of on.
1958     * @throws { BusinessError } 401 - Parameter error.
1959     * @syscap SystemCapability.Communication.NetStack
1960     * @since 11
1961     */
1962    /**
1963     * Listens for connect events of the LocalSocketServer connection.
1964     * @param { 'connect' } type - Indicates Event name.
1965     * @param { Callback<LocalSocketConnection> } callback - The callback of on.
1966     * @throws { BusinessError } 401 - Parameter error.
1967     * @syscap SystemCapability.Communication.NetStack
1968     * @crossplatform
1969     * @since 12
1970     */
1971    on(type: 'connect', callback: Callback<LocalSocketConnection>): void;
1972
1973    /**
1974     * Cancels listening for connect events of the LocalSocketServer connection.
1975     * @param { 'connect' } type - Indicates Event name.
1976     * @param { Callback<LocalSocketConnection> } callback - The callback of off.
1977     * @throws { BusinessError } 401 - Parameter error.
1978     * @syscap SystemCapability.Communication.NetStack
1979     * @since 11
1980     */
1981    /**
1982     * Cancels listening for connect events of the LocalSocketServer connection.
1983     * @param { 'connect' } type - Indicates Event name.
1984     * @param { Callback<LocalSocketConnection> } callback - The callback of off.
1985     * @throws { BusinessError } 401 - Parameter error.
1986     * @syscap SystemCapability.Communication.NetStack
1987     * @crossplatform
1988     * @since 12
1989     */
1990    off(type: 'connect', callback?: Callback<LocalSocketConnection>): void;
1991
1992    /**
1993     * Listens for error events of the LocalSocketServer connection.
1994     * @param { 'error' } type - Indicates Event name.
1995     * @param { ErrorCallback } callback - The callback of on.
1996     * @throws { BusinessError } 401 - Parameter error.
1997     * @syscap SystemCapability.Communication.NetStack
1998     * @since 11
1999     */
2000    /**
2001     * Listens for error events of the LocalSocketServer connection.
2002     * @param { 'error' } type - Indicates Event name.
2003     * @param { ErrorCallback } callback - The callback of on.
2004     * @throws { BusinessError } 401 - Parameter error.
2005     * @syscap SystemCapability.Communication.NetStack
2006     * @crossplatform
2007     * @since 12
2008     */
2009    on(type: 'error', callback: ErrorCallback): void;
2010
2011    /**
2012     * Cancels listening for error events of the LocalSocketServer connection.
2013     * @param { 'error' } type - Indicates Event name.
2014     * @param { ErrorCallback } callback - The callback of off.
2015     * @throws { BusinessError } 401 - Parameter error.
2016     * @syscap SystemCapability.Communication.NetStack
2017     * @since 11
2018     */
2019    /**
2020     * Cancels listening for error events of the LocalSocketServer connection.
2021     * @param { 'error' } type - Indicates Event name.
2022     * @param { ErrorCallback } callback - The callback of off.
2023     * @throws { BusinessError } 401 - Parameter error.
2024     * @syscap SystemCapability.Communication.NetStack
2025     * @crossplatform
2026     * @since 12
2027     */
2028    off(type: 'error', callback?: ErrorCallback): void;
2029  }
2030
2031  /**
2032   * Defines TCPSocket connection parameters.
2033   * @interface TCPConnectOptions
2034   * @syscap SystemCapability.Communication.NetStack
2035   * @since 7
2036   */
2037  /**
2038   * Defines TCPSocket connection parameters.
2039   * @interface TCPConnectOptions
2040   * @syscap SystemCapability.Communication.NetStack
2041   * @crossplatform
2042   * @since 10
2043   */
2044  export interface TCPConnectOptions {
2045    /**
2046     * Bound IP address and port number.
2047     * @type { NetAddress }
2048     * @syscap SystemCapability.Communication.NetStack
2049     * @since 7
2050     */
2051    /**
2052     * Bound IP address and port number.
2053     * @type { NetAddress }
2054     * @syscap SystemCapability.Communication.NetStack
2055     * @crossplatform
2056     * @since 10
2057     */
2058    address: NetAddress;
2059
2060    /**
2061     * Timeout duration of the TCPSocket connection, in milliseconds.
2062     * @type { ?number }
2063     * @syscap SystemCapability.Communication.NetStack
2064     * @since 7
2065     */
2066    /**
2067     * Timeout duration of the TCPSocket connection, in milliseconds.
2068     * @type { ?number }
2069     * @syscap SystemCapability.Communication.NetStack
2070     * @crossplatform
2071     * @since 10
2072     */
2073    timeout?: number;
2074
2075    /**
2076     * Destination proxy.
2077     * @type {ProxyOptions}
2078     * @syscap SystemCapability.Communication.NetStack
2079     * @crossplatform
2080     * @since 16
2081     */
2082    proxy?: ProxyOptions;
2083  }
2084
2085  /**
2086   * Defines the parameters for sending data over the TCPSocket connection.
2087   * @interface TCPSendOptions
2088   * @syscap SystemCapability.Communication.NetStack
2089   * @since 7
2090   */
2091  /**
2092   * Defines the parameters for sending data over the TCPSocket connection.
2093   * @interface TCPSendOptions
2094   * @syscap SystemCapability.Communication.NetStack
2095   * @crossplatform
2096   * @since 10
2097   */
2098  export interface TCPSendOptions {
2099    /**
2100     * Data to send.
2101     * @type { string | ArrayBuffer }
2102     * @syscap SystemCapability.Communication.NetStack
2103     * @since 7
2104     */
2105    /**
2106     * Data to send.
2107     * @type { string | ArrayBuffer }
2108     * @syscap SystemCapability.Communication.NetStack
2109     * @crossplatform
2110     * @since 10
2111     */
2112    data: string | ArrayBuffer;
2113
2114    /**
2115     * Character encoding format.
2116     * @type { ?string }
2117     * @syscap SystemCapability.Communication.NetStack
2118     * @since 7
2119     */
2120    /**
2121     * Character encoding format.
2122     * @type { ?string }
2123     * @syscap SystemCapability.Communication.NetStack
2124     * @crossplatform
2125     * @since 10
2126     */
2127    encoding?: string;
2128  }
2129
2130  /**
2131   * Defines other properties of the TCPSocket connection.
2132   * @interface TCPExtraOptions
2133   * @syscap SystemCapability.Communication.NetStack
2134   * @since 7
2135   */
2136  /**
2137   * Defines other properties of the TCPSocket connection.
2138   * @interface TCPExtraOptions
2139   * @syscap SystemCapability.Communication.NetStack
2140   * @crossplatform
2141   * @since 10
2142   */
2143  export interface TCPExtraOptions extends ExtraOptionsBase {
2144    /**
2145     * Whether to keep the connection alive. The default value is false.
2146     * @type { ?boolean }
2147     * @syscap SystemCapability.Communication.NetStack
2148     * @since 7
2149     */
2150    /**
2151     * Whether to keep the connection alive. The default value is false.
2152     * @type { ?boolean }
2153     * @syscap SystemCapability.Communication.NetStack
2154     * @crossplatform
2155     * @since 10
2156     */
2157    keepAlive?: boolean;
2158
2159    /**
2160     * Whether to enable OOBInline. The default value is false.
2161     * @type { ?boolean }
2162     * @syscap SystemCapability.Communication.NetStack
2163     * @since 7
2164     */
2165    /**
2166     * Whether to enable OOBInline. The default value is false.
2167     * @type { ?boolean }
2168     * @syscap SystemCapability.Communication.NetStack
2169     * @crossplatform
2170     * @since 10
2171     */
2172    OOBInline?: boolean;
2173
2174    /**
2175     * Whether to enable no-delay on the TCPSocket connection. The default value is false.
2176     * @type { ?boolean }
2177     * @syscap SystemCapability.Communication.NetStack
2178     * @since 7
2179     */
2180    /**
2181     * Whether to enable no-delay on the TCPSocket connection. The default value is false.
2182     * @type { ?boolean }
2183     * @syscap SystemCapability.Communication.NetStack
2184     * @crossplatform
2185     * @since 10
2186     */
2187    TCPNoDelay?: boolean;
2188
2189    /**
2190     * Socket linger.
2191     * @type { ?object }
2192     * @syscap SystemCapability.Communication.NetStack
2193     * @crossplatform
2194     * @since 7
2195     */
2196    /**
2197     * Socket linger.
2198     * @type { ?object }
2199     * @syscap SystemCapability.Communication.NetStack
2200     * @crossplatform
2201     * @since 10
2202     */
2203    socketLinger?: { on: boolean, linger: number };
2204  }
2205
2206  /**
2207   * Defines a TCPSocket connection.
2208   * @interface TCPSocket
2209   * @syscap SystemCapability.Communication.NetStack
2210   * @since 7
2211   */
2212  /**
2213   * Defines a TCPSocket connection.
2214   * @interface TCPSocket
2215   * @syscap SystemCapability.Communication.NetStack
2216   * @crossplatform
2217   * @since 10
2218   */
2219  export interface TCPSocket {
2220    /**
2221     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
2222     * @permission ohos.permission.INTERNET
2223     * @param { NetAddress } address - Destination address. {@link NetAddress}
2224     * @param { AsyncCallback<void> } callback - Return the callback of bind.
2225     * @throws { BusinessError } 401 - Parameter error.
2226     * @throws { BusinessError } 201 - Permission denied.
2227     * @syscap SystemCapability.Communication.NetStack
2228     * @since 7
2229     */
2230    /**
2231     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
2232     * @permission ohos.permission.INTERNET
2233     * @param { NetAddress } address - Destination address. {@link NetAddress}
2234     * @param { AsyncCallback<void> } callback - the callback of bind.
2235     * @throws { BusinessError } 401 - Parameter error.
2236     * @throws { BusinessError } 201 - Permission denied.
2237     * @syscap SystemCapability.Communication.NetStack
2238     * @crossplatform
2239     * @since 10
2240     */
2241    bind(address: NetAddress, callback: AsyncCallback<void>): void;
2242
2243    /**
2244     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
2245     * @permission ohos.permission.INTERNET
2246     * @param { NetAddress } address - Destination address. {@link NetAddress}
2247     * @returns { Promise<void> } The promise returned by the function.
2248     * @throws { BusinessError } 401 - Parameter error.
2249     * @throws { BusinessError } 201 - Permission denied.
2250     * @syscap SystemCapability.Communication.NetStack
2251     * @since 7
2252     */
2253    /**
2254     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
2255     * @permission ohos.permission.INTERNET
2256     * @param { NetAddress } address - Destination address. {@link NetAddress}
2257     * @returns { Promise<void> } The promise returned by the function.
2258     * @throws { BusinessError } 401 - Parameter error.
2259     * @throws { BusinessError } 201 - Permission denied.
2260     * @syscap SystemCapability.Communication.NetStack
2261     * @crossplatform
2262     * @since 10
2263     */
2264    bind(address: NetAddress): Promise<void>;
2265
2266    /**
2267     * Sets up a connection to the specified IP address and port number.
2268     * @permission ohos.permission.INTERNET
2269     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
2270     * @param { AsyncCallback<void> } callback - the callback of connect.
2271     * @throws { BusinessError } 401 - Parameter error.
2272     * @throws { BusinessError } 201 - Permission denied.
2273     * @syscap SystemCapability.Communication.NetStack
2274     * @since 7
2275     */
2276    /**
2277     * Sets up a connection to the specified IP address and port number.
2278     * @permission ohos.permission.INTERNET
2279     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
2280     * @param { AsyncCallback<void> } callback - the callback of connect.
2281     * @throws { BusinessError } 401 - Parameter error.
2282     * @throws { BusinessError } 201 - Permission denied.
2283     * @syscap SystemCapability.Communication.NetStack
2284     * @crossplatform
2285     * @since 10
2286     */
2287    connect(options: TCPConnectOptions, callback: AsyncCallback<void>): void;
2288
2289    /**
2290     * Sets up a connection to the specified IP address and port number.
2291     * @permission ohos.permission.INTERNET
2292     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
2293     * @returns { Promise<void> } The promise returned by the function.
2294     * @throws { BusinessError } 401 - Parameter error.
2295     * @throws { BusinessError } 201 - Permission denied.
2296     * @syscap SystemCapability.Communication.NetStack
2297     * @since 7
2298     */
2299    /**
2300     * Sets up a connection to the specified IP address and port number.
2301     * @permission ohos.permission.INTERNET
2302     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
2303     * @returns { Promise<void> } The promise returned by the function.
2304     * @throws { BusinessError } 401 - Parameter error.
2305     * @throws { BusinessError } 201 - Permission denied.
2306     * @syscap SystemCapability.Communication.NetStack
2307     * @crossplatform
2308     * @since 10
2309     */
2310    connect(options: TCPConnectOptions): Promise<void>;
2311
2312    /**
2313     * Sends data over a TCPSocket connection.
2314     * @permission ohos.permission.INTERNET
2315     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
2316     * @param { AsyncCallback<void> } callback - the callback of send.
2317     * @throws { BusinessError } 401 - Parameter error.
2318     * @throws { BusinessError } 201 - Permission denied.
2319     * @syscap SystemCapability.Communication.NetStack
2320     * @since 7
2321     */
2322    /**
2323     * Sends data over a TCPSocket connection.
2324     * @permission ohos.permission.INTERNET
2325     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
2326     * @param { AsyncCallback<void> } callback - the callback of send.
2327     * @throws { BusinessError } 401 - Parameter error.
2328     * @throws { BusinessError } 201 - Permission denied.
2329     * @syscap SystemCapability.Communication.NetStack
2330     * @crossplatform
2331     * @since 10
2332     */
2333    send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
2334
2335    /**
2336     * Sends data over a TCPSocket connection.
2337     * @permission ohos.permission.INTERNET
2338     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
2339     * @returns { Promise<void> } The promise returned by the function.
2340     * @throws { BusinessError } 401 - Parameter error.
2341     * @throws { BusinessError } 201 - Permission denied.
2342     * @syscap SystemCapability.Communication.NetStack
2343     * @since 7
2344     */
2345    /**
2346     * Sends data over a TCPSocket connection.
2347     * @permission ohos.permission.INTERNET
2348     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
2349     * @returns { Promise<void> } The promise returned by the function.
2350     * @throws { BusinessError } 401 - Parameter error.
2351     * @throws { BusinessError } 201 - Permission denied.
2352     * @syscap SystemCapability.Communication.NetStack
2353     * @crossplatform
2354     * @since 10
2355     */
2356    send(options: TCPSendOptions): Promise<void>;
2357
2358    /**
2359     * Closes a TCPSocket connection.
2360     * @permission ohos.permission.INTERNET
2361     * @param { AsyncCallback<void> } callback - the callback of close.
2362     * @throws { BusinessError } 201 - Permission denied.
2363     * @syscap SystemCapability.Communication.NetStack
2364     * @since 7
2365     */
2366    /**
2367     * Closes a TCPSocket connection.
2368     * @permission ohos.permission.INTERNET
2369     * @param { AsyncCallback<void> } callback - the callback of close.
2370     * @throws { BusinessError } 201 - Permission denied.
2371     * @syscap SystemCapability.Communication.NetStack
2372     * @crossplatform
2373     * @since 10
2374     */
2375    close(callback: AsyncCallback<void>): void;
2376
2377    /**
2378     * Closes a TCPSocket connection.
2379     * @permission ohos.permission.INTERNET
2380     * @returns { Promise<void> } The promise returned by the function.
2381     * @throws { BusinessError } 201 - Permission denied.
2382     * @syscap SystemCapability.Communication.NetStack
2383     * @since 7
2384     */
2385    /**
2386     * Closes a TCPSocket connection.
2387     * @permission ohos.permission.INTERNET
2388     * @returns { Promise<void> } The promise returned by the function.
2389     * @throws { BusinessError } 201 - Permission denied.
2390     * @syscap SystemCapability.Communication.NetStack
2391     * @crossplatform
2392     * @since 10
2393     */
2394    close(): Promise<void>;
2395
2396    /**
2397     * Obtains the peer address of a TCPSocket connection.
2398     * @permission ohos.permission.INTERNET
2399     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress. {@link NetAddress}
2400     * @throws { BusinessError } 201 - Permission denied.
2401     * @syscap SystemCapability.Communication.NetStack
2402     * @since 7
2403     */
2404    /**
2405     * Obtains the peer address of a TCPSocket connection.
2406     * @permission ohos.permission.INTERNET
2407     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress. {@link NetAddress}
2408     * @throws { BusinessError } 201 - Permission denied.
2409     * @syscap SystemCapability.Communication.NetStack
2410     * @crossplatform
2411     * @since 10
2412     */
2413    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
2414
2415    /**
2416     * Obtains the peer address of a TCPSocket connection.
2417     * @permission ohos.permission.INTERNET
2418     * @returns { Promise<NetAddress> } The promise returned by the function.
2419     * @throws { BusinessError } 201 - Permission denied.
2420     * @syscap SystemCapability.Communication.NetStack
2421     * @since 7
2422     */
2423    /**
2424     * Obtains the peer address of a TCPSocket connection.
2425     * @permission ohos.permission.INTERNET
2426     * @returns { Promise<NetAddress> } The promise returned by the function.
2427     * @throws { BusinessError } 201 - Permission denied.
2428     * @syscap SystemCapability.Communication.NetStack
2429     * @crossplatform
2430     * @since 10
2431     */
2432    getRemoteAddress(): Promise<NetAddress>;
2433
2434    /**
2435     * Obtains the status of the TCPSocket connection.
2436     * @permission ohos.permission.INTERNET
2437     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}
2438     * @throws { BusinessError } 201 - Permission denied.
2439     * @syscap SystemCapability.Communication.NetStack
2440     * @since 7
2441     */
2442    /**
2443     * Obtains the status of the TCPSocket connection.
2444     * @permission ohos.permission.INTERNET
2445     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}
2446     * @throws { BusinessError } 201 - Permission denied.
2447     * @syscap SystemCapability.Communication.NetStack
2448     * @crossplatform
2449     * @since 10
2450     */
2451    getState(callback: AsyncCallback<SocketStateBase>): void;
2452
2453    /**
2454     * Obtains the status of the TCPSocket connection.
2455     * @permission ohos.permission.INTERNET
2456     * @returns { Promise<SocketStateBase> } The promise returned by the function.
2457     * @throws { BusinessError } 201 - Permission denied.
2458     * @syscap SystemCapability.Communication.NetStack
2459     * @since 7
2460     */
2461    /**
2462     * Obtains the status of the TCPSocket connection.
2463     * @permission ohos.permission.INTERNET
2464     * @returns { Promise<SocketStateBase> } The promise returned by the function.
2465     * @throws { BusinessError } 201 - Permission denied.
2466     * @syscap SystemCapability.Communication.NetStack
2467     * @crossplatform
2468     * @since 10
2469     */
2470    getState(): Promise<SocketStateBase>;
2471
2472    /**
2473     * Obtains the file descriptor of the TCPSocket connection.
2474     * @param { AsyncCallback<number> } callback - The callback returns the file descriptor of the TCPSocket connection.
2475     * @syscap SystemCapability.Communication.NetStack
2476     * @since 10
2477     */
2478    getSocketFd(callback: AsyncCallback<number>): void;
2479
2480    /**
2481     * Obtains the file descriptor of the TCPSocket connection.
2482     * @returns { Promise<number> } The promise returns the file descriptor of the TCPSocket connection.
2483     * @syscap SystemCapability.Communication.NetStack
2484     * @since 10
2485     */
2486    getSocketFd(): Promise<number>;
2487
2488    /**
2489     * Sets other attributes of the TCPSocket connection.
2490     * @permission ohos.permission.INTERNET
2491     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
2492     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
2493     * @throws { BusinessError } 401 - Parameter error.
2494     * @throws { BusinessError } 201 - Permission denied.
2495     * @syscap SystemCapability.Communication.NetStack
2496     * @since 7
2497     */
2498    /**
2499     * Sets other attributes of the TCPSocket connection.
2500     * @permission ohos.permission.INTERNET
2501     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
2502     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
2503     * @throws { BusinessError } 401 - Parameter error.
2504     * @throws { BusinessError } 201 - Permission denied.
2505     * @syscap SystemCapability.Communication.NetStack
2506     * @crossplatform
2507     * @since 10
2508     */
2509    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
2510
2511    /**
2512     * Sets other attributes of the TCPSocket connection.
2513     * @permission ohos.permission.INTERNET
2514     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
2515     * @returns { Promise<void> } The promise returned by the function.
2516     * @throws { BusinessError } 401 - Parameter error.
2517     * @throws { BusinessError } 201 - Permission denied.
2518     * @syscap SystemCapability.Communication.NetStack
2519     * @since 7
2520     */
2521    /**
2522     * Sets other attributes of the TCPSocket connection.
2523     * @permission ohos.permission.INTERNET
2524     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
2525     * @returns { Promise<void> } The promise returned by the function.
2526     * @throws { BusinessError } 401 - Parameter error.
2527     * @throws { BusinessError } 201 - Permission denied.
2528     * @syscap SystemCapability.Communication.NetStack
2529     * @crossplatform
2530     * @since 10
2531     */
2532    setExtraOptions(options: TCPExtraOptions): Promise<void>;
2533
2534    /**
2535     * Obtains the local address of a TCPSocket connection.
2536     * @returns { Promise<NetAddress> } The promise returned by the function.
2537     * @throws { BusinessError } 2300002 - System internal error.
2538     * @throws { BusinessError } 2301009 - Bad file descriptor.
2539     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2540     * @syscap SystemCapability.Communication.NetStack
2541     * @since 12
2542     */
2543    getLocalAddress(): Promise<NetAddress>;
2544
2545    /**
2546     * Listens for message receiving events of the TCPSocket connection.
2547     * @param { 'message' } type - Indicates Event name.
2548     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
2549     * @syscap SystemCapability.Communication.NetStack
2550     * @since 7
2551     */
2552    /**
2553     * Listens for message receiving events of the TCPSocket connection.
2554     * @param { 'message' } type Indicates Event name.
2555     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
2556     * @syscap SystemCapability.Communication.NetStack
2557     * @crossplatform
2558     * @since 10
2559     */
2560    /**
2561     * Listens for message receiving events of the TCPSocket connection.
2562     * @param { 'message' } type Indicates Event name.
2563     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
2564     * @syscap SystemCapability.Communication.NetStack
2565     * @crossplatform
2566     * @since 11
2567     */
2568    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
2569
2570    /**
2571     * Cancels listening for message receiving events of the TCPSocket connection.
2572     * @param { 'message' } type Indicates Event name.
2573     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
2574     * @syscap SystemCapability.Communication.NetStack
2575     * @since 7
2576     */
2577    /**
2578     * Cancels listening for message receiving events of the TCPSocket connection.
2579     * @param { 'message' } type Indicates Event name.
2580     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
2581     * @syscap SystemCapability.Communication.NetStack
2582     * @crossplatform
2583     * @since 10
2584     */
2585    /**
2586     * Cancels listening for message receiving events of the TCPSocket connection.
2587     * @param { 'message' } type Indicates Event name.
2588     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
2589     * @syscap SystemCapability.Communication.NetStack
2590     * @crossplatform
2591     * @since 11
2592     */
2593    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
2594
2595
2596    /**
2597     * Listens for connection or close events of the TCPSocket connection.
2598     * @param { 'connect' | 'close' } type - Indicates Event name.
2599     * @param { Callback<void> } callback - the callback used to return the result.
2600     * @syscap SystemCapability.Communication.NetStack
2601     * @since 7
2602     */
2603    /**
2604     * Listens for connection or close events of the TCPSocket connection.
2605     * @param { 'connect' | 'close' } type - Indicates Event name.
2606     * @param { Callback<void> } callback - the callback used to return the result.
2607     * @syscap SystemCapability.Communication.NetStack
2608     * @crossplatform
2609     * @since 10
2610     */
2611    on(type: 'connect' | 'close', callback: Callback<void>): void;
2612
2613    /**
2614     * Cancels listening for connection or close events of the TCPSocket connection.
2615     * @param { 'connect' | 'close' } type - Indicates Event name.
2616     * @param { Callback<void> } callback - the callback used to return the result.
2617     * @syscap SystemCapability.Communication.NetStack
2618     * @since 7
2619     */
2620    /**
2621     * Cancels listening for connection or close events of the TCPSocket connection.
2622     * @param { 'connect' | 'close' } type - Indicates Event name.
2623     * @param { Callback<void> } callback - the callback used to return the result.
2624     * @syscap SystemCapability.Communication.NetStack
2625     * @crossplatform
2626     * @since 10
2627     */
2628    off(type: 'connect' | 'close', callback?: Callback<void>): void;
2629
2630    /**
2631     * Listens for error events of the TCPSocket connection.
2632     * @param { 'error' } type - Indicates Event name.
2633     * @param { ErrorCallback } callback - the callback used to return the result.
2634     * @syscap SystemCapability.Communication.NetStack
2635     * @since 7
2636     */
2637    /**
2638     * Listens for error events of the TCPSocket connection.
2639     * @param { 'error' } type - Indicates Event name.
2640     * @param { ErrorCallback } callback - the callback used to return the result.
2641     * @syscap SystemCapability.Communication.NetStack
2642     * @crossplatform
2643     * @since 10
2644     */
2645    on(type: 'error', callback: ErrorCallback): void;
2646
2647    /**
2648     * Cancels listening for error events of the TCPSocket connection.
2649     * @param { 'error' } type - Indicates Event name.
2650     * @param { ErrorCallback } callback - the callback used to return the result.
2651     * @syscap SystemCapability.Communication.NetStack
2652     * @since 7
2653     */
2654    /**
2655     * Cancels listening for error events of the TCPSocket connection.
2656     * @param { 'error' } type - Indicates Event name.
2657     * @param { ErrorCallback } callback - the callback used to return the result.
2658     * @syscap SystemCapability.Communication.NetStack
2659     * @crossplatform
2660     * @since 10
2661     */
2662    off(type: 'error', callback?: ErrorCallback): void;
2663  }
2664
2665  /**
2666   * Defines a TLSSocket connection.
2667   * @interface TLSSocket
2668   * @syscap SystemCapability.Communication.NetStack
2669   * @since 9
2670   */
2671  /**
2672   * Defines a TLSSocket connection.
2673   * @interface TLSSocket
2674   * @syscap SystemCapability.Communication.NetStack
2675   * @crossplatform
2676   * @since 10
2677   */
2678  export interface TLSSocket {
2679    /**
2680     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
2681     * @permission ohos.permission.INTERNET
2682     * @param { NetAddress } address - Destination address. {@link NetAddress}
2683     * @param { AsyncCallback<void> } callback - the callback of bind.
2684     * @throws { BusinessError } 401 - Parameter error.
2685     * @throws { BusinessError } 201 - Permission denied.
2686     * @throws { BusinessError } 2303198 - Address already in use.
2687     * @throws { BusinessError } 2300002 - System internal error.
2688     * @syscap SystemCapability.Communication.NetStack
2689     * @since 9
2690     */
2691    /**
2692     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
2693     * @permission ohos.permission.INTERNET
2694     * @param { NetAddress } address - Destination address. {@link NetAddress}
2695     * @param { AsyncCallback<void> } callback - the callback of bind.
2696     * @throws { BusinessError } 401 - Parameter error.
2697     * @throws { BusinessError } 201 - Permission denied.
2698     * @throws { BusinessError } 2303198 - Address already in use.
2699     * @throws { BusinessError } 2300002 - System internal error.
2700     * @syscap SystemCapability.Communication.NetStack
2701     * @crossplatform
2702     * @since 10
2703     */
2704    bind(address: NetAddress, callback: AsyncCallback<void>): void;
2705
2706    /**
2707     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
2708     * @permission ohos.permission.INTERNET
2709     * @param { NetAddress } address - Destination address. {@link NetAddress}
2710     * @returns { Promise<void> } The promise returned by the function.
2711     * @throws { BusinessError } 401 - Parameter error.
2712     * @throws { BusinessError } 201 - Permission denied.
2713     * @throws { BusinessError } 2303198 - Address already in use.
2714     * @throws { BusinessError } 2300002 - System internal error.
2715     * @syscap SystemCapability.Communication.NetStack
2716     * @since 9
2717     */
2718    /**
2719     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
2720     * @permission ohos.permission.INTERNET
2721     * @param { NetAddress } address - Destination address. {@link NetAddress}
2722     * @returns { Promise<void> } The promise returned by the function.
2723     * @throws { BusinessError } 401 - Parameter error.
2724     * @throws { BusinessError } 201 - Permission denied.
2725     * @throws { BusinessError } 2303198 - Address already in use.
2726     * @throws { BusinessError } 2300002 - System internal error.
2727     * @syscap SystemCapability.Communication.NetStack
2728     * @crossplatform
2729     * @since 10
2730     */
2731    bind(address: NetAddress): Promise<void>;
2732
2733    /**
2734     * Obtains the peer address of a TLSSocket connection.
2735     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress.
2736     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2737     * @throws { BusinessError } 2300002 - System internal error.
2738     * @syscap SystemCapability.Communication.NetStack
2739     * @since 9
2740     */
2741    /**
2742     * Obtains the peer address of a TLSSocket connection.
2743     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress.
2744     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2745     * @throws { BusinessError } 2300002 - System internal error.
2746     * @syscap SystemCapability.Communication.NetStack
2747     * @crossplatform
2748     * @since 10
2749     */
2750    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
2751
2752    /**
2753     * Obtains the peer address of a TLSSocket connection.
2754     * @returns { Promise<NetAddress> } The promise returned by the function.
2755     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2756     * @throws { BusinessError } 2300002 - System internal error.
2757     * @syscap SystemCapability.Communication.NetStack
2758     * @since 9
2759     */
2760    /**
2761     * Obtains the peer address of a TLSSocket connection.
2762     * @returns { Promise<NetAddress> } The promise returned by the function.
2763     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2764     * @throws { BusinessError } 2300002 - System internal error.
2765     * @syscap SystemCapability.Communication.NetStack
2766     * @crossplatform
2767     * @since 10
2768     */
2769    getRemoteAddress(): Promise<NetAddress>;
2770
2771    /**
2772     * Obtains the status of the TLSSocket connection.
2773     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState.
2774     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2775     * @throws { BusinessError } 2300002 - System internal error.
2776     * @syscap SystemCapability.Communication.NetStack
2777     * @since 9
2778     */
2779    /**
2780     * Obtains the status of the TLSSocket connection.
2781     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState.
2782     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2783     * @throws { BusinessError } 2300002 - System internal error.
2784     * @syscap SystemCapability.Communication.NetStack
2785     * @crossplatform
2786     * @since 10
2787     */
2788    getState(callback: AsyncCallback<SocketStateBase>): void;
2789
2790    /**
2791     * Obtains the status of the TLSSocket connection.
2792     * @returns { Promise<SocketStateBase> } The promise returned by the function.
2793     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2794     * @throws { BusinessError } 2300002 - System internal error.
2795     * @syscap SystemCapability.Communication.NetStack
2796     * @since 9
2797     */
2798    /**
2799     * Obtains the status of the TLSSocket connection.
2800     * @returns { Promise<SocketStateBase> } The promise returned by the function.
2801     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2802     * @throws { BusinessError } 2300002 - System internal error.
2803     * @syscap SystemCapability.Communication.NetStack
2804     * @crossplatform
2805     * @since 10
2806     */
2807    getState(): Promise<SocketStateBase>;
2808
2809    /**
2810     * Sets other attributes of the TLSSocket connection.
2811     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
2812     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
2813     * @throws { BusinessError } 401 - Parameter error.
2814     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2815     * @throws { BusinessError } 2300002 - System internal error.
2816     * @syscap SystemCapability.Communication.NetStack
2817     * @since 9
2818     */
2819    /**
2820     * Sets other attributes of the TLSSocket connection.
2821     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
2822     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
2823     * @throws { BusinessError } 401 - Parameter error.
2824     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2825     * @throws { BusinessError } 2300002 - System internal error.
2826     * @syscap SystemCapability.Communication.NetStack
2827     * @crossplatform
2828     * @since 10
2829     */
2830    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
2831
2832    /**
2833     * Sets other attributes of the TLSSocket connection.
2834     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
2835     * @returns { Promise<void> } The promise returned by the function.
2836     * @throws { BusinessError } 401 - Parameter error.
2837     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2838     * @throws { BusinessError } 2300002 - System internal error.
2839     * @syscap SystemCapability.Communication.NetStack
2840     * @since 9
2841     */
2842    /**
2843     * Sets other attributes of the TLSSocket connection.
2844     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
2845     * @returns { Promise<void> } The promise returned by the function.
2846     * @throws { BusinessError } 401 - Parameter error.
2847     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2848     * @throws { BusinessError } 2300002 - System internal error.
2849     * @syscap SystemCapability.Communication.NetStack
2850     * @crossplatform
2851     * @since 10
2852     */
2853    setExtraOptions(options: TCPExtraOptions): Promise<void>;
2854
2855    /**
2856     * Obtains the local address of a TLSSocket connection.
2857     * @returns { Promise<NetAddress> } The promise returned by the function.
2858     * @throws { BusinessError } 2300002 - System internal error.
2859     * @throws { BusinessError } 2301009 - Bad file descriptor.
2860     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2861     * @syscap SystemCapability.Communication.NetStack
2862     * @since 12
2863     */
2864    getLocalAddress(): Promise<NetAddress>;
2865
2866    /**
2867     * Listens for message receiving events of the TLSSocket connection.
2868     * @param { 'message' } type - Indicates Event name.
2869     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
2870     * @throws { BusinessError } 401 - Parameter error.
2871     * @syscap SystemCapability.Communication.NetStack
2872     * @since 9
2873     */
2874    /**
2875     * Listens for message receiving events of the TLSSocket connection.
2876     * @param { 'message' } type Indicates Event name.
2877     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
2878     * @throws { BusinessError } 401 - Parameter error.
2879     * @syscap SystemCapability.Communication.NetStack
2880     * @crossplatform
2881     * @since 10
2882     */
2883    /**
2884     * Listens for message receiving events of the TLSSocket connection.
2885     * @param { 'message' } type Indicates Event name.
2886     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
2887     * @throws { BusinessError } 401 - Parameter error.
2888     * @syscap SystemCapability.Communication.NetStack
2889     * @crossplatform
2890     * @since 11
2891     */
2892    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
2893
2894    /**
2895     * Cancels listening for message receiving events of the TLSSocket connection.
2896     * @param { 'message' } type - Indicates Event name.
2897     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
2898     * @throws { BusinessError } 401 - Parameter error.
2899     * @syscap SystemCapability.Communication.NetStack
2900     * @since 9
2901     */
2902    /**
2903     * Cancels listening for message receiving events of the TLSSocket connection.
2904     * @param { 'message' } type Indicates Event name.
2905     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
2906     * @throws { BusinessError } 401 - Parameter error.
2907     * @syscap SystemCapability.Communication.NetStack
2908     * @crossplatform
2909     * @since 10
2910     */
2911    /**
2912     * Cancels listening for message receiving events of the TLSSocket connection.
2913     * @param { 'message' } type Indicates Event name.
2914     * @param { Callback<SocketMessageInfo> } callback - the callback used to return the result.
2915     * @throws { BusinessError } 401 - Parameter error.
2916     * @syscap SystemCapability.Communication.NetStack
2917     * @crossplatform
2918     * @since 11
2919     */
2920    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
2921
2922    /**
2923     * Listens for connection or close events of the TLSSocket connection.
2924     * @param { 'connect' | 'close' } type - Indicates Event name.
2925     * @param {Callback<void> } callback - the callback used to return the result.
2926     * @throws { BusinessError } 401 - Parameter error.
2927     * @syscap SystemCapability.Communication.NetStack
2928     * @since 9
2929     */
2930    /**
2931     * Listens for connection or close events of the TLSSocket connection.
2932     * @param { 'connect' | 'close' } type - Indicates Event name.
2933     * @param {Callback<void> } callback - the callback used to return the result.
2934     * @throws { BusinessError } 401 - Parameter error.
2935     * @syscap SystemCapability.Communication.NetStack
2936     * @crossplatform
2937     * @since 10
2938     */
2939    on(type: 'connect' | 'close', callback: Callback<void>): void;
2940
2941    /**
2942     * Cancels listening for connection or close events of the TLSSocket connection.
2943     * @param { 'connect' | 'close' } type - Indicates Event name.
2944     * @param {Callback<void> } callback - the callback used to return the result.
2945     * @throws { BusinessError } 401 - Parameter error.
2946     * @syscap SystemCapability.Communication.NetStack
2947     * @since 9
2948     */
2949    /**
2950     * Cancels listening for connection or close events of the TLSSocket connection.
2951     * @param { 'connect' | 'close' } type - Indicates Event name.
2952     * @param {Callback<void> } callback - the callback used to return the result.
2953     * @throws { BusinessError } 401 - Parameter error.
2954     * @syscap SystemCapability.Communication.NetStack
2955     * @crossplatform
2956     * @since 10
2957     */
2958    off(type: 'connect' | 'close', callback?: Callback<void>): void;
2959
2960    /**
2961     * Listens for error events of the TLSSocket connection.
2962     * @param { 'error' } type - Indicates Event name.
2963     * @param { ErrorCallback } callback - the callback used to return the result.
2964     * @throws { BusinessError } 401 - Parameter error.
2965     * @syscap SystemCapability.Communication.NetStack
2966     * @since 9
2967     */
2968    /**
2969     * Listens for error events of the TLSSocket connection.
2970     * @param { 'error' } type - Indicates Event name.
2971     * @param { ErrorCallback } callback - the callback used to return the result.
2972     * @throws { BusinessError } 401 - Parameter error.
2973     * @syscap SystemCapability.Communication.NetStack
2974     * @crossplatform
2975     * @since 10
2976     */
2977    on(type: 'error', callback: ErrorCallback): void;
2978
2979    /**
2980     * Cancels listening for error events of the TLSSocket connection.
2981     * @param { 'error' } type - Indicates Event name.
2982     * @param { ErrorCallback } callback - the callback used to return the result.
2983     * @throws { BusinessError } 401 - Parameter error.
2984     * @syscap SystemCapability.Communication.NetStack
2985     * @since 9
2986     */
2987    /**
2988     * Cancels listening for error events of the TLSSocket connection.
2989     * @param { 'error' } type - Indicates Event name.
2990     * @param { ErrorCallback } callback - the callback used to return the result.
2991     * @throws { BusinessError } 401 - Parameter error.
2992     * @syscap SystemCapability.Communication.NetStack
2993     * @crossplatform
2994     * @since 10
2995     */
2996    off(type: 'error', callback?: ErrorCallback): void;
2997
2998    /**
2999     * Returns an object representing a local certificate.
3000     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getCertificate.
3001     * @throws { BusinessError } 2303501 - SSL is null.
3002     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
3003     * @throws { BusinessError } 2300002 - System internal error.
3004     * @syscap SystemCapability.Communication.NetStack
3005     * @since 9
3006     */
3007    /**
3008     * Returns an object representing a local certificate.
3009     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getCertificate.
3010     * @throws { BusinessError } 2303501 - SSL is null.
3011     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
3012     * @throws { BusinessError } 2300002 - System internal error.
3013     * @syscap SystemCapability.Communication.NetStack
3014     * @crossplatform
3015     * @since 10
3016     */
3017    getCertificate(callback: AsyncCallback<X509CertRawData>): void;
3018
3019    /**
3020     * Returns an object representing a local certificate.
3021     * @returns { Promise<X509CertRawData> } The promise returned by the function.
3022     * @throws { BusinessError } 2303501 - SSL is null.
3023     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
3024     * @throws { BusinessError } 2300002 - System internal error.
3025     * @syscap SystemCapability.Communication.NetStack
3026     * @since 9
3027     */
3028    /**
3029     * Returns an object representing a local certificate.
3030     * @returns { Promise<X509CertRawData> } The promise returned by the function.
3031     * @throws { BusinessError } 2303501 - SSL is null.
3032     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
3033     * @throws { BusinessError } 2300002 - System internal error.
3034     * @syscap SystemCapability.Communication.NetStack
3035     * @crossplatform
3036     * @since 10
3037     */
3038    getCertificate(): Promise<X509CertRawData>;
3039
3040    /**
3041     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
3042     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
3043     * It only contains the peer's certificate.
3044     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getRemoteCertificate.
3045     * @throws { BusinessError } 2303501 - SSL is null.
3046     * @throws { BusinessError } 2300002 - System internal error.
3047     * @syscap SystemCapability.Communication.NetStack
3048     * @since 9
3049     */
3050    /**
3051     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
3052     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
3053     * It only contains the peer's certificate.
3054     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getRemoteCertificate.
3055     * @throws { BusinessError } 2303501 - SSL is null.
3056     * @throws { BusinessError } 2300002 - System internal error.
3057     * @syscap SystemCapability.Communication.NetStack
3058     * @crossplatform
3059     * @since 10
3060     */
3061    getRemoteCertificate(callback: AsyncCallback<X509CertRawData>): void;
3062
3063    /**
3064     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
3065     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
3066     * It only contains the peer's certificate.
3067     * @returns { Promise<X509CertRawData> } The promise returned by the function.
3068     * @throws { BusinessError } 2303501 - SSL is null.
3069     * @throws { BusinessError } 2300002 - System internal error.
3070     * @syscap SystemCapability.Communication.NetStack
3071     * @since 9
3072     */
3073    /**
3074     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
3075     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
3076     * It only contains the peer's certificate.
3077     * @returns { Promise<X509CertRawData> } The promise returned by the function.
3078     * @throws { BusinessError } 2303501 - SSL is null.
3079     * @throws { BusinessError } 2300002 - System internal error.
3080     * @syscap SystemCapability.Communication.NetStack
3081     * @crossplatform
3082     * @since 10
3083     */
3084    getRemoteCertificate(): Promise<X509CertRawData>;
3085
3086    /**
3087     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
3088     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
3089     * Server sockets or disconnected client sockets will return a value of null.
3090     * @param { AsyncCallback<string> } callback - the callback of getProtocol.
3091     * @throws { BusinessError } 2303501 - SSL is null.
3092     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3093     * @throws { BusinessError } 2300002 - System internal error.
3094     * @syscap SystemCapability.Communication.NetStack
3095     * @since 9
3096     */
3097    /**
3098     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
3099     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
3100     * Server sockets or disconnected client sockets will return a value of null.
3101     * @param { AsyncCallback<string> } callback - the callback of getProtocol.
3102     * @throws { BusinessError } 2303501 - SSL is null.
3103     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3104     * @throws { BusinessError } 2300002 - System internal error.
3105     * @syscap SystemCapability.Communication.NetStack
3106     * @crossplatform
3107     * @since 10
3108     */
3109    getProtocol(callback: AsyncCallback<string>): void;
3110
3111    /**
3112     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
3113     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
3114     * Server sockets or disconnected client sockets will return a value of null.
3115     * @returns { Promise<string> } The promise returned by the function.
3116     * @throws { BusinessError } 2303501 - SSL is null.
3117     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3118     * @throws { BusinessError } 2300002 - System internal error.
3119     * @syscap SystemCapability.Communication.NetStack
3120     * @since 9
3121     */
3122    /**
3123     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
3124     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
3125     * Server sockets or disconnected client sockets will return a value of null.
3126     * @returns { Promise<string> } The promise returned by the function.
3127     * @throws { BusinessError } 2303501 - SSL is null.
3128     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3129     * @throws { BusinessError } 2300002 - System internal error.
3130     * @syscap SystemCapability.Communication.NetStack
3131     * @crossplatform
3132     * @since 10
3133     */
3134    getProtocol(): Promise<string>;
3135
3136    /**
3137     * Returns a list containing the negotiated cipher suite information.
3138     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
3139     * @param { AsyncCallback<Array<string>> } callback - the callback of getCipherSuite.
3140     * @throws { BusinessError } 2303501 - SSL is null.
3141     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
3142     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3143     * @throws { BusinessError } 2300002 - System internal error.
3144     * @syscap SystemCapability.Communication.NetStack
3145     * @since 9
3146     */
3147    /**
3148     * Returns a list containing the negotiated cipher suite information.
3149     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
3150     * @param { AsyncCallback<Array<string>> } callback - the callback of getCipherSuite.
3151     * @throws { BusinessError } 2303501 - SSL is null.
3152     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
3153     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3154     * @throws { BusinessError } 2300002 - System internal error.
3155     * @syscap SystemCapability.Communication.NetStack
3156     * @crossplatform
3157     * @since 10
3158     */
3159    getCipherSuite(callback: AsyncCallback<Array<string>>): void;
3160
3161    /**
3162     * Returns a list containing the negotiated cipher suite information.
3163     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
3164     * @returns { Promise<Array<string>> } The promise returned by the function.
3165     * @throws { BusinessError } 2303501 - SSL is null.
3166     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
3167     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3168     * @throws { BusinessError } 2300002 - System internal error.
3169     * @syscap SystemCapability.Communication.NetStack
3170     * @since 9
3171     */
3172    /**
3173     * Returns a list containing the negotiated cipher suite information.
3174     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
3175     * @returns { Promise<Array<string>> } The promise returned by the function.
3176     * @throws { BusinessError } 2303501 - SSL is null.
3177     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
3178     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3179     * @throws { BusinessError } 2300002 - System internal error.
3180     * @syscap SystemCapability.Communication.NetStack
3181     * @crossplatform
3182     * @since 10
3183     */
3184    getCipherSuite(): Promise<Array<string>>;
3185
3186    /**
3187     * <p>The list of signature algorithms shared between the server and the client,
3188     * in descending order of priority.</p>
3189     * @param { AsyncCallback<Array<string>> } callback - the callback of getSignatureAlgorithms.@see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html
3190     * @throws { BusinessError } 2303501 - SSL is null.
3191     * @throws { BusinessError } 2300002 - System internal error.
3192     * @syscap SystemCapability.Communication.NetStack
3193     * @since 9
3194     */
3195    /**
3196     * <p>The list of signature algorithms shared between the server and the client,
3197     * in descending order of priority.</p>
3198     * @param { AsyncCallback<Array<string>> } callback - the callback of getSignatureAlgorithms.@see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html
3199     * @throws { BusinessError } 2303501 - SSL is null.
3200     * @throws { BusinessError } 2300002 - System internal error.
3201     * @syscap SystemCapability.Communication.NetStack
3202     * @crossplatform
3203     * @since 10
3204     */
3205    getSignatureAlgorithms(callback: AsyncCallback<Array<string>>): void;
3206
3207    /**
3208     * <p>The list of signature algorithms shared between the server and the client,
3209     * in descending order of priority.</p>
3210     * @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
3211     * @throws { BusinessError } 2303501 - SSL is null.
3212     * @throws { BusinessError } 2300002 - System internal error.
3213     * @syscap SystemCapability.Communication.NetStack
3214     * @since 9
3215     */
3216    /**
3217     * <p>The list of signature algorithms shared between the server and the client,
3218     * in descending order of priority.</p>
3219     * @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
3220     * @throws { BusinessError } 2303501 - SSL is null.
3221     * @throws { BusinessError } 2300002 - System internal error.
3222     * @syscap SystemCapability.Communication.NetStack
3223     * @crossplatform
3224     * @since 10
3225     */
3226    getSignatureAlgorithms(): Promise<Array<string>>;
3227
3228    /**
3229     * Sets up a connection to the specified IP address and port number.
3230     * Only TCP is supported.
3231     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
3232     * @param { AsyncCallback<void> } callback - the callback of connect.
3233     * @throws { BusinessError } 401 - Parameter error.
3234     * @throws { BusinessError } 2303104 - Interrupted system call.
3235     * @throws { BusinessError } 2303109 - Bad file number.
3236     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
3237     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3238     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
3239     * @throws { BusinessError } 2303198 - Address already in use.
3240     * @throws { BusinessError } 2303199 - Cannot assign requested address.
3241     * @throws { BusinessError } 2303210 - Connection timed out.
3242     * @throws { BusinessError } 2303501 - SSL is null.
3243     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
3244     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3245     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3246     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3247     * @throws { BusinessError } 2300002 - System internal error.
3248     * @syscap SystemCapability.Communication.NetStack
3249     * @since 9
3250     */
3251    /**
3252     * Sets up a connection to the specified IP address and port number.
3253     * Only TCP is supported.
3254     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
3255     * @param { AsyncCallback<void> } callback - the callback of connect.
3256     * @throws { BusinessError } 401 - Parameter error.
3257     * @throws { BusinessError } 2303104 - Interrupted system call.
3258     * @throws { BusinessError } 2303109 - Bad file number.
3259     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
3260     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3261     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
3262     * @throws { BusinessError } 2303198 - Address already in use.
3263     * @throws { BusinessError } 2303199 - Cannot assign requested address.
3264     * @throws { BusinessError } 2303210 - Connection timed out.
3265     * @throws { BusinessError } 2303501 - SSL is null.
3266     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
3267     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3268     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3269     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3270     * @throws { BusinessError } 2300002 - System internal error.
3271     * @syscap SystemCapability.Communication.NetStack
3272     * @crossplatform
3273     * @since 10
3274     */
3275    connect(options: TLSConnectOptions, callback: AsyncCallback<void>): void;
3276
3277    /**
3278     * Sets up a connection to the specified IP address and port number.
3279     * Only TCP is supported.
3280     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
3281     * @returns { Promise<void> } The promise returned by the function.
3282     * @throws { BusinessError } 401 - Parameter error.
3283     * @throws { BusinessError } 2303104 - Interrupted system call.
3284     * @throws { BusinessError } 2303109 - Bad file number.
3285     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
3286     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3287     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
3288     * @throws { BusinessError } 2303198 - Address already in use.
3289     * @throws { BusinessError } 2303199 - Cannot assign requested address.
3290     * @throws { BusinessError } 2303210 - Connection timed out.
3291     * @throws { BusinessError } 2303501 - SSL is null.
3292     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
3293     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3294     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3295     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3296     * @throws { BusinessError } 2300002 - System internal error.
3297     * @syscap SystemCapability.Communication.NetStack
3298     * @since 9
3299     */
3300    /**
3301     * Sets up a connection to the specified IP address and port number.
3302     * Only TCP is supported.
3303     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
3304     * @returns { Promise<void> } The promise returned by the function.
3305     * @throws { BusinessError } 401 - Parameter error.
3306     * @throws { BusinessError } 2303104 - Interrupted system call.
3307     * @throws { BusinessError } 2303109 - Bad file number.
3308     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
3309     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3310     * @throws { BusinessError } 2303191 - Incorrect socket protocol type.
3311     * @throws { BusinessError } 2303198 - Address already in use.
3312     * @throws { BusinessError } 2303199 - Cannot assign requested address.
3313     * @throws { BusinessError } 2303210 - Connection timed out.
3314     * @throws { BusinessError } 2303501 - SSL is null.
3315     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
3316     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3317     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3318     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3319     * @throws { BusinessError } 2300002 - System internal error.
3320     * @syscap SystemCapability.Communication.NetStack
3321     * @crossplatform
3322     * @since 10
3323     */
3324    connect(options: TLSConnectOptions): Promise<void>;
3325
3326    /**
3327     * Sends data over a TLSSocket connection.
3328     * @param { string } data - Parameters for sending data {@link string}.
3329     * @param { AsyncCallback<void> } callback - the callback of send.
3330     * @throws { BusinessError } 401 - Parameter error.
3331     * @throws { BusinessError } 2303501 - SSL is null.
3332     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3333     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3334     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3335     * @throws { BusinessError } 2300002 - System internal error.
3336     * @syscap SystemCapability.Communication.NetStack
3337     * @since 9
3338     */
3339    /**
3340     * Sends data over a TLSSocket connection.
3341     * @param { string } data - Parameters for sending data {@link string}.
3342     * @param { AsyncCallback<void> } callback - the callback of send.
3343     * @throws { BusinessError } 401 - Parameter error.
3344     * @throws { BusinessError } 2303501 - SSL is null.
3345     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3346     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3347     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3348     * @throws { BusinessError } 2300002 - System internal error.
3349     * @syscap SystemCapability.Communication.NetStack
3350     * @crossplatform
3351     * @since 10
3352     */
3353    /**
3354     * Sends data over a TLSSocket connection.
3355     * @param { string | ArrayBuffer } data - Parameters for sending data.
3356     * @param { AsyncCallback<void> } callback - the callback of send.
3357     * @throws { BusinessError } 401 - Parameter error.
3358     * @throws { BusinessError } 2303501 - SSL is null.
3359     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3360     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3361     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3362     * @throws { BusinessError } 2300002 - System internal error.
3363     * @syscap SystemCapability.Communication.NetStack
3364     * @crossplatform
3365     * @since 12
3366     */
3367    send(data: string | ArrayBuffer, callback: AsyncCallback<void>): void;
3368
3369    /**
3370     * Sends data over a TLSSocket connection.
3371     * @param { string } data - Parameters for sending data {@link string}.
3372     * @returns { Promise<void> } The promise returned by the function.
3373     * @throws { BusinessError } 401 - Parameter error.
3374     * @throws { BusinessError } 2303501 - SSL is null.
3375     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3376     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3377     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3378     * @throws { BusinessError } 2300002 - System internal error.
3379     * @syscap SystemCapability.Communication.NetStack
3380     * @since 9
3381     */
3382    /**
3383     * Sends data over a TLSSocket connection.
3384     * @param { string } data - Parameters for sending data {@link string}.
3385     * @returns { Promise<void> } The promise returned by the function.
3386     * @throws { BusinessError } 401 - Parameter error.
3387     * @throws { BusinessError } 2303501 - SSL is null.
3388     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3389     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3390     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3391     * @throws { BusinessError } 2300002 - System internal error.
3392     * @syscap SystemCapability.Communication.NetStack
3393     * @crossplatform
3394     * @since 10
3395     */
3396    /**
3397     * Sends data over a TLSSocket connection.
3398     * @param { string | ArrayBuffer } data - Parameters for sending data.
3399     * @returns { Promise<void> } The promise returned by the function.
3400     * @throws { BusinessError } 401 - Parameter error.
3401     * @throws { BusinessError } 2303501 - SSL is null.
3402     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
3403     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3404     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3405     * @throws { BusinessError } 2300002 - System internal error.
3406     * @syscap SystemCapability.Communication.NetStack
3407     * @crossplatform
3408     * @since 12
3409     */
3410    send(data: string | ArrayBuffer): Promise<void>;
3411
3412    /**
3413     * Closes a TLSSocket connection
3414     * @param { AsyncCallback<void> } callback - the callback of close.
3415     * @throws { BusinessError } 401 - Parameter error.
3416     * @throws { BusinessError } 2303501 - SSL is null.
3417     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3418     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3419     * @throws { BusinessError } 2300002 - System internal error.
3420     * @syscap SystemCapability.Communication.NetStack
3421     * @since 9
3422     */
3423    /**
3424     * Closes a TLSSocket connection
3425     * @param { AsyncCallback<void> } callback - the callback of close.
3426     * @throws { BusinessError } 401 - Parameter error.
3427     * @throws { BusinessError } 2303501 - SSL is null.
3428     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3429     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3430     * @throws { BusinessError } 2300002 - System internal error.
3431     * @syscap SystemCapability.Communication.NetStack
3432     * @crossplatform
3433     * @since 10
3434     */
3435    close(callback: AsyncCallback<void>): void;
3436
3437    /**
3438     * Closes a TLSSocket connection
3439     * @returns { Promise<void> } The promise returned by the function.
3440     * @throws { BusinessError } 401 - Parameter error.
3441     * @throws { BusinessError } 2303501 - SSL is null.
3442     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3443     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3444     * @throws { BusinessError } 2300002 - System internal error.
3445     * @syscap SystemCapability.Communication.NetStack
3446     * @since 9
3447     */
3448    /**
3449     * Closes a TLSSocket connection
3450     * @returns { Promise<void> } The promise returned by the function.
3451     * @throws { BusinessError } 401 - Parameter error.
3452     * @throws { BusinessError } 2303501 - SSL is null.
3453     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
3454     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
3455     * @throws { BusinessError } 2300002 - System internal error.
3456     * @syscap SystemCapability.Communication.NetStack
3457     * @crossplatform
3458     * @since 10
3459     */
3460    close(): Promise<void>;
3461  }
3462
3463  /**
3464   * Defines TLS security options. The CA certificate is mandatory, and other parameters are optional.
3465   * @interface TLSSecureOptions
3466   * @syscap SystemCapability.Communication.NetStack
3467   * @since 9
3468   */
3469  /**
3470   * Defines TLS security options. The CA certificate is mandatory, and other parameters are optional.
3471   * @interface TLSSecureOptions
3472   * @syscap SystemCapability.Communication.NetStack
3473   * @crossplatform
3474   * @since 10
3475   */
3476  export interface TLSSecureOptions {
3477    /**
3478     * Certificate used to verify the identity of the server
3479     * @type {string | Array<string>}
3480     * @syscap SystemCapability.Communication.NetStack
3481     * @since 9
3482     */
3483    /**
3484     * Certificate used to verify the identity of the server.
3485     * @type {string | Array<string>}
3486     * @syscap SystemCapability.Communication.NetStack
3487     * @crossplatform
3488     * @since 10
3489     */
3490    /**
3491     * Certificate used to verify the identity of the server, if it is not set, use system ca.
3492     * @type {?(string | Array<string>)}
3493     * @syscap SystemCapability.Communication.NetStack
3494     * @crossplatform
3495     * @since 12
3496     */
3497    ca?: string | Array<string>;
3498
3499    /**
3500     * Certificate proving the identity of the client
3501     * @type {?string}
3502     * @syscap SystemCapability.Communication.NetStack
3503     * @since 9
3504     */
3505    /**
3506     * Certificate proving the identity of the client
3507     * @type {?string}
3508     * @syscap SystemCapability.Communication.NetStack
3509     * @crossplatform
3510     * @since 10
3511     */
3512    cert?: string;
3513
3514    /**
3515     * Private key of client certificate
3516     * @type {?string}
3517     * @syscap SystemCapability.Communication.NetStack
3518     * @since 9
3519     */
3520    /**
3521     * Private key of client certificate
3522     * @type {?string}
3523     * @syscap SystemCapability.Communication.NetStack
3524     * @crossplatform
3525     * @since 10
3526     */
3527    key?: string;
3528
3529    /**
3530     * Password of the private key
3531     * @type {?string}
3532     * @syscap SystemCapability.Communication.NetStack
3533     * @since 9
3534     */
3535    /**
3536     * Password of the private key
3537     * @type {?string}
3538     * @syscap SystemCapability.Communication.NetStack
3539     * @crossplatform
3540     * @since 10
3541     */
3542    password?: string;
3543
3544    /**
3545     * TLS protocol version
3546     * @type {?Protocol | Array<Protocol>}
3547     * @syscap SystemCapability.Communication.NetStack
3548     * @since 9
3549     */
3550    /**
3551     * TLS protocol version
3552     * @type {?(Protocol | Array<Protocol>)}
3553     * @syscap SystemCapability.Communication.NetStack
3554     * @crossplatform
3555     * @since 10
3556     */
3557    protocols?: Protocol | Array<Protocol>;
3558
3559    /**
3560     * default is false, use local cipher.
3561     * @type {?boolean}
3562     * @syscap SystemCapability.Communication.NetStack
3563     * @since 9
3564     */
3565    /**
3566     * default is false, use local cipher.
3567     * @type {?boolean}
3568     * @syscap SystemCapability.Communication.NetStack
3569     * @crossplatform
3570     * @since 10
3571     */
3572    useRemoteCipherPrefer?: boolean;
3573
3574    /**
3575     * <P>Supported signature algorithms. This string can contain summary algorithms(SHA256,MD5,etc),Public key algorithm(RSA-PSS,ECDSA,etc),
3576     * Combination of the two(For example 'RSA+SHA384') or TLS v1.3 Scheme name(For example  rsa_pss_pss_sha512)</P>
3577     * @type {?string}
3578     * @syscap SystemCapability.Communication.NetStack
3579     * @since 9
3580     */
3581    /**
3582     * <P>Supported signature algorithms. This string can contain summary algorithms(SHA256,MD5,etc),Public key algorithm(RSA-PSS,ECDSA,etc),
3583     * Combination of the two(For example 'RSA+SHA384') or TLS v1.3 Scheme name(For example  rsa_pss_pss_sha512)</P>
3584     * @type {?string}
3585     * @syscap SystemCapability.Communication.NetStack
3586     * @crossplatform
3587     * @since 10
3588     */
3589    signatureAlgorithms?: string;
3590
3591    /**
3592     * Crypto suite specification
3593     * @type {?string}
3594     * @syscap SystemCapability.Communication.NetStack
3595     * @since 9
3596     */
3597    /**
3598     * Crypto suite specification
3599     * @type {?string}
3600     * @syscap SystemCapability.Communication.NetStack
3601     * @crossplatform
3602     * @since 10
3603     */
3604    cipherSuite?: string;
3605
3606    /**
3607     * Used to set up bidirectional authentication. The default value is false.
3608     * @type {?boolean}
3609     * @syscap SystemCapability.Communication.NetStack
3610     * @since 12
3611     */
3612    isBidirectionalAuthentication?: boolean;
3613  }
3614
3615  /**
3616   * Defines TLS connection options.
3617   * @interface TLSConnectOptions
3618   * @syscap SystemCapability.Communication.NetStack
3619   * @since 9
3620   */
3621  /**
3622   * Defines TLS connection options.
3623   * @interface TLSConnectOptions
3624   * @syscap SystemCapability.Communication.NetStack
3625   * @crossplatform
3626   * @since 10
3627   */
3628  export interface TLSConnectOptions {
3629    /**
3630     * Gateway address.
3631     * @type {NetAddress}
3632     * @syscap SystemCapability.Communication.NetStack
3633     * @since 9
3634     */
3635    /**
3636     * Gateway address.
3637     * @type {NetAddress}
3638     * @syscap SystemCapability.Communication.NetStack
3639     * @crossplatform
3640     * @since 10
3641     */
3642    address: NetAddress;
3643
3644    /**
3645     * Protocol http2TLS security related operations.
3646     * @type {TLSSecureOptions}
3647     * @syscap SystemCapability.Communication.NetStack
3648     * @since 9
3649     */
3650    /**
3651     * Protocol http2TLS security related operations.
3652     * @type {TLSSecureOptions}
3653     * @syscap SystemCapability.Communication.NetStack
3654     * @crossplatform
3655     * @since 10
3656     */
3657    secureOptions: TLSSecureOptions;
3658
3659    /**
3660     * Application layer protocol negotiation extension, such as "spdy/1", "http/1.1", "h2"
3661     * @type {?Array<string>}
3662     * @syscap SystemCapability.Communication.NetStack
3663     * @since 9
3664     */
3665    /**
3666     * Application layer protocol negotiation extension, such as "spdy/1", "http/1.1", "h2"
3667     * @type {?Array<string>}
3668     * @syscap SystemCapability.Communication.NetStack
3669     * @crossplatform
3670     * @since 10
3671     */
3672    ALPNProtocols?: Array<string>;
3673
3674    /**
3675     * Skip identity verification for remote servers. The default value is false.
3676     * @type {?boolean}
3677     * @syscap SystemCapability.Communication.NetStack
3678     * @since 12
3679     */
3680    skipRemoteValidation?: boolean;
3681
3682    /**
3683     * Destination proxy.
3684     * @type {ProxyOptions}
3685     * @syscap SystemCapability.Communication.NetStack
3686     * @crossplatform
3687     * @since 16
3688     */
3689    proxy?: ProxyOptions;
3690  }
3691
3692  /**
3693   * Enumerates TLS protocol versions.
3694   * @enum {string}
3695   * @syscap SystemCapability.Communication.NetStack
3696   * @since 9
3697   */
3698  /**
3699   * Enumerates TLS protocol versions.
3700   * @enum {string}
3701   * @syscap SystemCapability.Communication.NetStack
3702   * @crossplatform
3703   * @since 10
3704   */
3705  export enum Protocol {
3706    /**
3707     * Use TLSv1.2 protocol for communication.
3708     * @syscap SystemCapability.Communication.NetStack
3709     * @since 9
3710     */
3711    /**
3712     * Use TLSv1.2 protocol for communication.
3713     * @syscap SystemCapability.Communication.NetStack
3714     * @crossplatform
3715     * @since 10
3716     */
3717    TLSv12 = "TLSv1.2",
3718
3719    /**
3720     * Use TLSv1.3 protocol for communication.
3721     * @syscap SystemCapability.Communication.NetStack
3722     * @since 9
3723     */
3724    /**
3725     * Use TLSv1.3 protocol for communication.
3726     * @syscap SystemCapability.Communication.NetStack
3727     * @crossplatform
3728     * @since 10
3729     */
3730    TLSv13 = "TLSv1.3"
3731  }
3732
3733  /**
3734   * Defines the connection of the TCPSocket client and server.
3735   * @interface TCPSocketConnection
3736   * @syscap SystemCapability.Communication.NetStack
3737   * @since 10
3738   */
3739  export interface TCPSocketConnection {
3740    /**
3741     * The id of a client connects to the TCPSocketServer.
3742     * @type {number}
3743     * @syscap SystemCapability.Communication.NetStack
3744     * @since 10
3745     */
3746    clientId: number;
3747
3748    /**
3749     * Sends data over a TCPSocketServer connection to client.
3750     * @permission ohos.permission.INTERNET
3751     * @param { TCPSendOptions } options - Parameters for sending data {@link TCPSendOptions}.
3752     * @param { AsyncCallback<void> } callback - The callback of send.
3753     * @throws { BusinessError } 201 - Permission denied.
3754     * @throws { BusinessError } 401 - Parameter error.
3755     * @throws { BusinessError } 2300002 - System internal error.
3756     * @syscap SystemCapability.Communication.NetStack
3757     * @since 10
3758     */
3759    send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
3760
3761    /**
3762     * Sends data over a TCPSocketServer connection to client.
3763     * @permission ohos.permission.INTERNET
3764     * @param { TCPSendOptions } options - Parameters for sending data {@link TCPSendOptions}.
3765     * @returns { Promise<void> } The promise returned by the function.
3766     * @throws { BusinessError } 201 - Permission denied.
3767     * @throws { BusinessError } 401 - Parameter error.
3768     * @throws { BusinessError } 2300002 - System internal error.
3769     * @syscap SystemCapability.Communication.NetStack
3770     * @since 10
3771     */
3772    send(options: TCPSendOptions): Promise<void>;
3773
3774    /**
3775     * Closes a TCPSocket client connection.
3776     * @permission ohos.permission.INTERNET
3777     * @param { AsyncCallback<void> } callback - The callback of close.
3778     * @throws { BusinessError } 201 - Permission denied.
3779     * @throws { BusinessError } 401 - Parameter error.
3780     * @throws { BusinessError } 2300002 - System internal error.
3781     * @syscap SystemCapability.Communication.NetStack
3782     * @since 10
3783     */
3784    close(callback: AsyncCallback<void>): void;
3785
3786    /**
3787     * Closes a TCPSocket client connection.
3788     * @permission ohos.permission.INTERNET
3789     * @returns { Promise<void> } The promise returned by the function.
3790     * @throws { BusinessError } 201 - Permission denied.
3791     * @throws { BusinessError } 2300002 - System internal error.
3792     * @syscap SystemCapability.Communication.NetStack
3793     * @since 10
3794     */
3795    close(): Promise<void>;
3796
3797    /**
3798     * Obtains the peer address of a TCPSocketServer connection.
3799     * @permission ohos.permission.INTERNET
3800     * @param { AsyncCallback<NetAddress> } callback - The callback of getRemoteAddress.
3801     * @throws { BusinessError } 201 - Permission denied.
3802     * @throws { BusinessError } 401 - Parameter error.
3803     * @throws { BusinessError } 2300002 - System internal error.
3804     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3805     * @syscap SystemCapability.Communication.NetStack
3806     * @since 10
3807     */
3808    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
3809
3810    /**
3811     * Obtains the peer address of a TCPSocketServer connection.
3812     * @permission ohos.permission.INTERNET
3813     * @returns { Promise<NetAddress> } The promise returned by the function.
3814     * @throws { BusinessError } 201 - Permission denied.
3815     * @throws { BusinessError } 2300002 - System internal error.
3816     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3817     * @syscap SystemCapability.Communication.NetStack
3818     * @since 10
3819     */
3820    getRemoteAddress(): Promise<NetAddress>;
3821
3822    /**
3823     * Obtains the local address of a TCPSocketServer connection.
3824     * @returns { Promise<NetAddress> } The promise returned by the function.
3825     * @throws { BusinessError } 2300002 - System internal error.
3826     * @throws { BusinessError } 2301009 - Bad file descriptor.
3827     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3828     * @syscap SystemCapability.Communication.NetStack
3829     * @since 12
3830     */
3831    getLocalAddress(): Promise<NetAddress>;
3832
3833    /**
3834     * Listens for message receiving events of the TCPSocketConnection.
3835     * @param { 'message' } type - Indicates Event name.
3836     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of on.
3837     * @throws { BusinessError } 401 - Parameter error.
3838     * @syscap SystemCapability.Communication.NetStack
3839     * @since 10
3840     */
3841    /**
3842     * Listens for message receiving events of the TCPSocketConnection.
3843     * @param { 'message' } type - Indicates Event name.
3844     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
3845     * @throws { BusinessError } 401 - Parameter error.
3846     * @syscap SystemCapability.Communication.NetStack
3847     * @since 11
3848     */
3849    /**
3850     * Listens for message receiving events of the TCPSocketConnection.
3851     * @param { 'message' } type - Indicates Event name.
3852     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
3853     * @throws { BusinessError } 401 - Parameter error.
3854     * @syscap SystemCapability.Communication.NetStack
3855     * @crossplatform
3856     * @since 12
3857     */
3858    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
3859
3860    /**
3861     * Cancels listening for message receiving events of the TCPSocketConnection.
3862     * @param { 'message' } type - Indicates Event name.
3863     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of off.
3864     * @throws { BusinessError } 401 - Parameter error.
3865     * @syscap SystemCapability.Communication.NetStack
3866     * @since 10
3867     */
3868    /**
3869     * Cancels listening for message receiving events of the TCPSocketConnection.
3870     * @param { 'message' } type - Indicates Event name.
3871     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
3872     * @throws { BusinessError } 401 - Parameter error.
3873     * @syscap SystemCapability.Communication.NetStack
3874     * @since 11
3875     */
3876    /**
3877     * Cancels listening for message receiving events of the TCPSocketConnection.
3878     * @param { 'message' } type - Indicates Event name.
3879     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
3880     * @throws { BusinessError } 401 - Parameter error.
3881     * @syscap SystemCapability.Communication.NetStack
3882     * @crossplatform
3883     * @since 12
3884     */
3885    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
3886
3887    /**
3888     * Listens for close events of the TCPSocketConnection.
3889     * @param { 'close' } type - Indicates Event name.
3890     * @param { Callback<void> } callback - The callback of on.
3891     * @throws { BusinessError } 401 - Parameter error.
3892     * @syscap SystemCapability.Communication.NetStack
3893     * @since 10
3894     */
3895    on(type: 'close', callback: Callback<void>): void;
3896
3897    /**
3898     * Cancels listening for close events of the TCPSocketConnection.
3899     * @param { 'close' } type - Indicates Event name.
3900     * @param { Callback<void> } callback - The callback of off.
3901     * @throws { BusinessError } 401 - Parameter error.
3902     * @syscap SystemCapability.Communication.NetStack
3903     * @since 10
3904     */
3905    off(type: 'close', callback?: Callback<void>): void;
3906
3907    /**
3908     * Listens for error events of the TCPSocketConnection.
3909     * @param { 'error' } type - Indicates Event name.
3910     * @param { ErrorCallback } callback - The callback of on.
3911     * @throws { BusinessError } 401 - Parameter error.
3912     * @syscap SystemCapability.Communication.NetStack
3913     * @since 10
3914     */
3915    on(type: 'error', callback: ErrorCallback): void;
3916
3917    /**
3918     * Cancels listening for error events of the TCPSocketConnection.
3919     * @param { 'error' } type - Indicates Event name.
3920     * @param { ErrorCallback } callback - The callback of off.
3921     * @throws { BusinessError } 401 - Parameter error.
3922     * @syscap SystemCapability.Communication.NetStack
3923     * @since 10
3924     */
3925    off(type: 'error', callback?: ErrorCallback): void;
3926  }
3927
3928  /**
3929   * Defines a TCPSocket server connection.
3930   * @interface TCPSocketServer
3931   * @syscap SystemCapability.Communication.NetStack
3932   * @since 10
3933   */
3934  export interface TCPSocketServer {
3935    /**
3936     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
3937     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
3938     * for accept processing and uses poll multiplex to process client connections.</p>
3939     * @permission ohos.permission.INTERNET
3940     * @param { NetAddress } address - Network address information {@link NetAddress}.
3941     * @param { AsyncCallback<void> } callback - The callback of listen.
3942     * @throws { BusinessError } 401 - Parameter error.
3943     * @throws { BusinessError } 201 - Permission denied.
3944     * @throws { BusinessError } 2300002 - System internal error.
3945     * @throws { BusinessError } 2303109 - Bad file number.
3946     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
3947     * @throws { BusinessError } 2303198 - Address already in use.
3948     * @throws { BusinessError } 2303199 - Cannot assign requested address.
3949     * @syscap SystemCapability.Communication.NetStack
3950     * @since 10
3951     */
3952    listen(address: NetAddress, callback: AsyncCallback<void>): void;
3953
3954    /**
3955     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
3956     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
3957     * for accept processing and uses poll multiplex to process client connections.</p>
3958     * @permission ohos.permission.INTERNET
3959     * @param { NetAddress } address - Network address information {@link NetAddress}.
3960     * @returns { Promise<void> } The promise returned by the function.
3961     * @throws { BusinessError } 401 - Parameter error.
3962     * @throws { BusinessError } 201 - Permission denied.
3963     * @throws { BusinessError } 2300002 - System internal error.
3964     * @throws { BusinessError } 2303109 - Bad file number.
3965     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
3966     * @throws { BusinessError } 2303198 - Address already in use.
3967     * @throws { BusinessError } 2303199 - Cannot assign requested address.
3968     * @syscap SystemCapability.Communication.NetStack
3969     * @since 10
3970     */
3971    listen(address: NetAddress): Promise<void>;
3972
3973    /**
3974     * Obtains the status of the TCPSocketServer connection.
3975     * @permission ohos.permission.INTERNET
3976     * @param { AsyncCallback<SocketStateBase> } callback - The callback of getState.
3977     * @throws { BusinessError } 201 - Permission denied.
3978     * @throws { BusinessError } 401 - Parameter error.
3979     * @throws { BusinessError } 2300002 - System internal error.
3980     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3981     * @syscap SystemCapability.Communication.NetStack
3982     * @since 10
3983     */
3984    getState(callback: AsyncCallback<SocketStateBase>): void;
3985
3986    /**
3987     * Obtains the status of the TCPSocketServer connection.
3988     * @permission ohos.permission.INTERNET
3989     * @returns { Promise<SocketStateBase> } The promise returned by the function.
3990     * @throws { BusinessError } 201 - Permission denied.
3991     * @throws { BusinessError } 2300002 - System internal error.
3992     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
3993     * @syscap SystemCapability.Communication.NetStack
3994     * @since 10
3995     */
3996    getState(): Promise<SocketStateBase>;
3997
3998    /**
3999     * Sets other attributes of the TCPSocketServer connection.
4000     * @permission ohos.permission.INTERNET
4001     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
4002     * @param { AsyncCallback<void> } callback - The callback of setExtraOptions.
4003     * @throws { BusinessError } 201 - Permission denied.
4004     * @throws { BusinessError } 401 - Parameter error.
4005     * @throws { BusinessError } 2300002 - System internal error.
4006     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4007     * @syscap SystemCapability.Communication.NetStack
4008     * @since 10
4009     */
4010    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
4011
4012    /**
4013     * Sets other attributes of the TCPSocketServer connection.
4014     * @permission ohos.permission.INTERNET
4015     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
4016     * @returns { Promise<void> } The promise returned by the function.
4017     * @throws { BusinessError } 201 - Permission denied.
4018     * @throws { BusinessError } 401 - Parameter error.
4019     * @throws { BusinessError } 2300002 - System internal error.
4020     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4021     * @syscap SystemCapability.Communication.NetStack
4022     * @since 10
4023     */
4024    setExtraOptions(options: TCPExtraOptions): Promise<void>;
4025
4026    /**
4027     * Obtains the local address of a TCPSocketServer connection.
4028     * @returns { Promise<NetAddress> } The promise returned by the function.
4029     * @throws { BusinessError } 2300002 - System internal error.
4030     * @throws { BusinessError } 2301009 - Bad file descriptor.
4031     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4032     * @syscap SystemCapability.Communication.NetStack
4033     * @since 12
4034     */
4035    getLocalAddress(): Promise<NetAddress>;
4036
4037    /**
4038     * Listens for connect events of the TCPSocketServer connection.
4039     * @param { 'connect' } type - Indicates Event name.
4040     * @param { Callback<TCPSocketConnection> } callback - The callback of on.
4041     * @throws { BusinessError } 401 - Parameter error.
4042     * @syscap SystemCapability.Communication.NetStack
4043     * @since 10
4044     */
4045    on(type: 'connect', callback: Callback<TCPSocketConnection>): void;
4046
4047    /**
4048     * Cancels listening for connect events of the TCPSocketServer connection.
4049     * @param { 'connect' } type - Indicates Event name.
4050     * @param { Callback<TCPSocketConnection> } callback - The callback of off.
4051     * @throws { BusinessError } 401 - Parameter error.
4052     * @syscap SystemCapability.Communication.NetStack
4053     * @since 10
4054     */
4055    off(type: 'connect', callback?: Callback<TCPSocketConnection>): void;
4056
4057    /**
4058     * Listens for error events of the TCPSocketServer connection.
4059     * @param { 'error' } type - Indicates Event name.
4060     * @param { ErrorCallback } callback - The callback of on.
4061     * @throws { BusinessError } 401 - Parameter error.
4062     * @syscap SystemCapability.Communication.NetStack
4063     * @since 10
4064     */
4065    on(type: 'error', callback: ErrorCallback): void;
4066
4067    /**
4068     * Cancels listening for error events of the TCPSocketServer connection.
4069     * @param { 'error' } type - Indicates Event name.
4070     * @param { ErrorCallback } callback - The callback of off.
4071     * @throws { BusinessError } 401 - Parameter error.
4072     * @syscap SystemCapability.Communication.NetStack
4073     * @since 10
4074     */
4075    off(type: 'error', callback?: ErrorCallback): void;
4076  }
4077
4078  /**
4079   * Defines the connection of the TLSSocket client and server.
4080   * @interface TLSSocketConnection
4081   * @syscap SystemCapability.Communication.NetStack
4082   * @since 10
4083   */
4084  export interface TLSSocketConnection {
4085    /**
4086     * The id of a client connects to the TLSSocketServer.
4087     * @type {number}
4088     * @syscap SystemCapability.Communication.NetStack
4089     * @since 10
4090     */
4091    clientId: number;
4092
4093    /**
4094     * Sends data over a TLSSocketServer connection to client.
4095     * @param { string } data - Parameters for sending data.
4096     * @param { AsyncCallback<void> } callback - The callback of send.
4097     * @throws { BusinessError } 401 - Parameter error.
4098     * @throws { BusinessError } 2303501 - SSL is null.
4099     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
4100     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4101     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
4102     * @throws { BusinessError } 2300002 - System internal error.
4103     * @syscap SystemCapability.Communication.NetStack
4104     * @since 10
4105     */
4106    /**
4107     * Sends data over a TLSSocketServer connection to client.
4108     * @param { string | ArrayBuffer } data - Parameters for sending data.
4109     * @param { AsyncCallback<void> } callback - The callback of send.
4110     * @throws { BusinessError } 401 - Parameter error.
4111     * @throws { BusinessError } 2303501 - SSL is null.
4112     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
4113     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4114     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
4115     * @throws { BusinessError } 2300002 - System internal error.
4116     * @syscap SystemCapability.Communication.NetStack
4117     * @since 12
4118     */
4119    send(data: string | ArrayBuffer, callback: AsyncCallback<void>): void;
4120
4121    /**
4122     * Sends data over a TLSSocketServer connection to client.
4123     * @param { string } data - Parameters for sending data.
4124     * @returns { Promise<void> } The promise returned by the function.
4125     * @throws { BusinessError } 401 - Parameter error.
4126     * @throws { BusinessError } 2303501 - SSL is null.
4127     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
4128     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4129     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
4130     * @throws { BusinessError } 2300002 - System internal error.
4131     * @syscap SystemCapability.Communication.NetStack
4132     * @since 10
4133     */
4134    /**
4135     * Sends data over a TLSSocketServer connection to client.
4136     * @param { string | ArrayBuffer } data - Parameters for sending data.
4137     * @returns { Promise<void> } The promise returned by the function.
4138     * @throws { BusinessError } 401 - Parameter error.
4139     * @throws { BusinessError } 2303501 - SSL is null.
4140     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
4141     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4142     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
4143     * @throws { BusinessError } 2300002 - System internal error.
4144     * @syscap SystemCapability.Communication.NetStack
4145     * @since 12
4146     */
4147    send(data: string | ArrayBuffer): Promise<void>;
4148
4149    /**
4150     * Closes a TLSSocket client connection.
4151     * @param { AsyncCallback<void> } callback - The callback of close.
4152     * @throws { BusinessError } 401 - Parameter error.
4153     * @throws { BusinessError } 2303501 - SSL is null.
4154     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4155     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
4156     * @throws { BusinessError } 2300002 - System internal error.
4157     * @syscap SystemCapability.Communication.NetStack
4158     * @since 10
4159     */
4160    close(callback: AsyncCallback<void>): void;
4161
4162    /**
4163     * Closes a TLSSocket client connection.
4164     * @returns { Promise<void> } The promise returned by the function.
4165     * @throws { BusinessError } 2303501 - SSL is null.
4166     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4167     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
4168     * @throws { BusinessError } 2300002 - System internal error.
4169     * @syscap SystemCapability.Communication.NetStack
4170     * @since 10
4171     */
4172    close(): Promise<void>;
4173
4174    /**
4175     * Obtains the peer address of a TLSSocketServer connection.
4176     * @param { AsyncCallback<NetAddress> } callback - The callback of getRemoteAddress.
4177     * @throws { BusinessError } 401 - Parameter error.
4178     * @throws { BusinessError } 2300002 - System internal error.
4179     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4180     * @syscap SystemCapability.Communication.NetStack
4181     * @since 10
4182     */
4183    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
4184
4185    /**
4186     * Obtains the peer address of a TLSSocketServer connection.
4187     * @returns { Promise<NetAddress> } The promise returned by the function.
4188     * @throws { BusinessError } 2300002 - System internal error.
4189     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4190     * @syscap SystemCapability.Communication.NetStack
4191     * @since 10
4192     */
4193    getRemoteAddress(): Promise<NetAddress>;
4194
4195    /**
4196     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
4197     * an empty object will be returned. If the socket is destroyed, null is returned.</p>
4198     * It only contains the peer's certificate.
4199     * @param { AsyncCallback<X509CertRawData> } callback - The callback of getRemoteCertificate.
4200     * @throws { BusinessError } 401 - Parameter error.
4201     * @throws { BusinessError } 2303501 - SSL is null.
4202     * @throws { BusinessError } 2300002 - System internal error.
4203     * @syscap SystemCapability.Communication.NetStack
4204     * @since 10
4205     */
4206    getRemoteCertificate(callback: AsyncCallback<X509CertRawData>): void;
4207
4208    /**
4209     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
4210     * an empty object will be returned. If the socket is destroyed, null is returned.</p>
4211     * It only contains the peer's certificate.
4212     * @returns { Promise<X509CertRawData> } The promise returned by the function.
4213     * @throws { BusinessError } 2303501 - SSL is null.
4214     * @throws { BusinessError } 2300002 - System internal error.
4215     * @syscap SystemCapability.Communication.NetStack
4216     * @since 10
4217     */
4218    getRemoteCertificate(): Promise<X509CertRawData>;
4219
4220    /**
4221     * Returns a list containing the negotiated cipher suite information.
4222     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
4223     * @param { AsyncCallback<Array<string>> } callback - The callback of getCipherSuite.
4224     * @throws { BusinessError } 401 - Parameter error.
4225     * @throws { BusinessError } 2303501 - SSL is null.
4226     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
4227     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4228     * @throws { BusinessError } 2300002 - System internal error.
4229     * @syscap SystemCapability.Communication.NetStack
4230     * @since 10
4231     */
4232    getCipherSuite(callback: AsyncCallback<Array<string>>): void;
4233
4234    /**
4235     * Returns a list containing the negotiated cipher suite information.
4236     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
4237     * @returns { Promise<Array<string>> } The promise returned by the function.
4238     * @throws { BusinessError } 2303501 - SSL is null.
4239     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
4240     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4241     * @throws { BusinessError } 2300002 - System internal error.
4242     * @syscap SystemCapability.Communication.NetStack
4243     * @since 10
4244     */
4245    getCipherSuite(): Promise<Array<string>>;
4246
4247    /**
4248     * <p>The list of signature algorithms shared between the server and the client,
4249     * in descending order of priority.</p>
4250     * @param { AsyncCallback<Array<string>> } callback - The callback of getSignatureAlgorithms.
4251     * @throws { BusinessError } 401 - Parameter error.
4252     * @throws { BusinessError } 2303501 - SSL is null.
4253     * @throws { BusinessError } 2300002 - System internal error.
4254     * @syscap SystemCapability.Communication.NetStack
4255     * @since 10
4256     */
4257    getSignatureAlgorithms(callback: AsyncCallback<Array<string>>): void;
4258
4259    /**
4260     * <p>The list of signature algorithms shared between the server and the client,
4261     * in descending order of priority.</p>
4262     * @returns { Promise<Array<string>> } The promise returned by the function.
4263     * @throws { BusinessError } 2303501 - SSL is null.
4264     * @throws { BusinessError } 2300002 - System internal error.
4265     * @syscap SystemCapability.Communication.NetStack
4266     * @since 10
4267     */
4268    getSignatureAlgorithms(): Promise<Array<string>>;
4269
4270    /**
4271     * Obtains the local address of a TLSSocketServer connection.
4272     * @returns { Promise<NetAddress> } The promise returned by the function.
4273     * @throws { BusinessError } 2300002 - System internal error.
4274     * @throws { BusinessError } 2301009 - Bad file descriptor.
4275     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4276     * @syscap SystemCapability.Communication.NetStack
4277     * @since 12
4278     */
4279    getLocalAddress(): Promise<NetAddress>;
4280
4281    /**
4282     * Listens for message receiving events of the TLSSocketConnection.
4283     * @param { 'message' } type - Indicates Event name.
4284     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of on.
4285     * @throws { BusinessError } 401 - Parameter error.
4286     * @syscap SystemCapability.Communication.NetStack
4287     * @since 10
4288     */
4289    /**
4290     * Listens for message receiving events of the TLSSocketConnection.
4291     * @param { 'message' } type - Indicates Event name.
4292     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
4293     * @throws { BusinessError } 401 - Parameter error.
4294     * @syscap SystemCapability.Communication.NetStack
4295     * @since 11
4296     */
4297    /**
4298     * Listens for message receiving events of the TLSSocketConnection.
4299     * @param { 'message' } type - Indicates Event name.
4300     * @param { Callback<SocketMessageInfo> } callback - The callback of on.
4301     * @throws { BusinessError } 401 - Parameter error.
4302     * @syscap SystemCapability.Communication.NetStack
4303     * @crossplatform
4304     * @since 12
4305     */
4306    on(type: 'message', callback: Callback<SocketMessageInfo>): void;
4307
4308    /**
4309     * Cancels listening for message receiving events of the TLSSocketConnection.
4310     * @param { 'message' } type - Indicates Event name.
4311     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of off.
4312     * @throws { BusinessError } 401 - Parameter error.
4313     * @syscap SystemCapability.Communication.NetStack
4314     * @since 10
4315     */
4316    /**
4317     * Cancels listening for message receiving events of the TLSSocketConnection.
4318     * @param { 'message' } type - Indicates Event name.
4319     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
4320     * @throws { BusinessError } 401 - Parameter error.
4321     * @syscap SystemCapability.Communication.NetStack
4322     * @since 11
4323     */
4324    /**
4325     * Cancels listening for message receiving events of the TLSSocketConnection.
4326     * @param { 'message' } type - Indicates Event name.
4327     * @param { Callback<SocketMessageInfo> } callback - The callback of off.
4328     * @throws { BusinessError } 401 - Parameter error.
4329     * @syscap SystemCapability.Communication.NetStack
4330     * @crossplatform
4331     * @since 12
4332     */
4333    off(type: 'message', callback?: Callback<SocketMessageInfo>): void;
4334
4335    /**
4336     * Listens for close events of the TLSSocketConnection.
4337     * @param { 'close' } type - Indicates Event name.
4338     * @param { Callback<void> } callback - The callback of on.
4339     * @throws { BusinessError } 401 - Parameter error.
4340     * @syscap SystemCapability.Communication.NetStack
4341     * @since 10
4342     */
4343    on(type: 'close', callback: Callback<void>): void;
4344
4345    /**
4346     * Cancels listening for close events of the TLSSocketConnection.
4347     * @param { 'close' } type - Indicates Event name.
4348     * @param { Callback<void> } callback - The callback of off.
4349     * @throws { BusinessError } 401 - Parameter error.
4350     * @syscap SystemCapability.Communication.NetStack
4351     * @since 10
4352     */
4353    off(type: 'close', callback?: Callback<void>): void;
4354
4355    /**
4356     * Listens for error events of the TLSSocketConnection.
4357     * @param { 'error' } type - Indicates Event name.
4358     * @param { ErrorCallback } callback - The callback of on.
4359     * @throws { BusinessError } 401 - Parameter error.
4360     * @syscap SystemCapability.Communication.NetStack
4361     * @since 10
4362     */
4363    on(type: 'error', callback: ErrorCallback): void;
4364
4365    /**
4366     * Cancels listening for error events of the TLSSocketConnection.
4367     * @param { 'error' } type - Indicates Event name.
4368     * @param { ErrorCallback } callback - The callback of off.
4369     * @throws { BusinessError } 401 - Parameter error.
4370     * @syscap SystemCapability.Communication.NetStack
4371     * @since 10
4372     */
4373    off(type: 'error', callback?: ErrorCallback): void;
4374  }
4375
4376  /**
4377   * Defines the socket connection information.
4378   * @interface SocketMessageInfo
4379   * @syscap SystemCapability.Communication.NetStack
4380   * @crossplatform
4381   * @since 11
4382   */
4383  export interface SocketMessageInfo {
4384    /**
4385     * Receive the message event.
4386     * @type { ArrayBuffer }
4387     * @syscap SystemCapability.Communication.NetStack
4388     * @crossplatform
4389     * @since 11
4390     */
4391    message: ArrayBuffer;
4392    /**
4393     * Socket connection information.
4394     * @type { SocketRemoteInfo }
4395     * @syscap SystemCapability.Communication.NetStack
4396     * @crossplatform
4397     * @since 11
4398     */
4399    remoteInfo: SocketRemoteInfo;
4400  }
4401
4402  /**
4403   * Defines a TLSSocketServer server connection.
4404   * @interface TLSSocketServer
4405   * @syscap SystemCapability.Communication.NetStack
4406   * @since 10
4407   */
4408  export interface TLSSocketServer {
4409    /**
4410     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
4411     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
4412     * for accept processing and uses poll multiplex to process client connections.</p>
4413     * @permission ohos.permission.INTERNET
4414     * @param { TLSConnectOptions } options - TLS connection options {@link TLSConnectOptions}.
4415     * @param { AsyncCallback<void> } callback - The callback of listen.
4416     * @throws { BusinessError } 401 - Parameter error.
4417     * @throws { BusinessError } 201 - Permission denied.
4418     * @throws { BusinessError } 2300002 - System internal error.
4419     * @throws { BusinessError } 2303109 - Bad file number.
4420     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
4421     * @throws { BusinessError } 2303198 - Address already in use.
4422     * @throws { BusinessError } 2303199 - Cannot assign requested address.
4423     * @throws { BusinessError } 2303501 - SSL is null.
4424     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
4425     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
4426     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4427     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
4428     * @syscap SystemCapability.Communication.NetStack
4429     * @since 10
4430     */
4431    listen(options: TLSConnectOptions, callback: AsyncCallback<void>): void;
4432
4433    /**
4434     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
4435     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
4436     * for accept processing and uses poll multiplex to process client connections.</p>
4437     * @permission ohos.permission.INTERNET
4438     * @param { TLSConnectOptions } options - TLS connection options {@link TLSConnectOptions}.
4439     * @returns { Promise<void> } The promise returned by the function.
4440     * @throws { BusinessError } 401 - Parameter error.
4441     * @throws { BusinessError } 201 - Permission denied.
4442     * @throws { BusinessError } 2300002 - System internal error.
4443     * @throws { BusinessError } 2303109 - Bad file number.
4444     * @throws { BusinessError } 2303111 - Resource temporarily unavailable. Try again.
4445     * @throws { BusinessError } 2303198 - Address already in use.
4446     * @throws { BusinessError } 2303199 - Cannot assign requested address.
4447     * @throws { BusinessError } 2303501 - SSL is null.
4448     * @throws { BusinessError } 2303502 - An error occurred when reading data on the TLS socket.
4449     * @throws { BusinessError } 2303503 - An error occurred when writing data on the TLS socket.
4450     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4451     * @throws { BusinessError } 2303506 - Failed to close the TLS connection.
4452     * @syscap SystemCapability.Communication.NetStack
4453     * @since 10
4454     */
4455    listen(options: TLSConnectOptions): Promise<void>;
4456
4457    /**
4458     * Obtains the status of the TLSSocketServer connection.
4459     * @param { AsyncCallback<SocketStateBase> } callback - The callback of getState.
4460     * @throws { BusinessError } 401 - Parameter error.
4461     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4462     * @throws { BusinessError } 2300002 - System internal error.
4463     * @syscap SystemCapability.Communication.NetStack
4464     * @since 10
4465     */
4466    getState(callback: AsyncCallback<SocketStateBase>): void;
4467
4468    /**
4469     * Obtains the status of the TLSSocketServer connection.
4470     * @returns { Promise<SocketStateBase> } The promise returned by the function.
4471     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4472     * @throws { BusinessError } 2300002 - System internal error.
4473     * @syscap SystemCapability.Communication.NetStack
4474     * @since 10
4475     */
4476    getState(): Promise<SocketStateBase>;
4477
4478    /**
4479     * Sets other attributes of the TLSSocketServer connection.
4480     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
4481     * @param { AsyncCallback<void> } callback - The callback of setExtraOptions.
4482     * @throws { BusinessError } 401 - Parameter error.
4483     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4484     * @throws { BusinessError } 2300002 - System internal error.
4485     * @syscap SystemCapability.Communication.NetStack
4486     * @since 10
4487     */
4488    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
4489
4490    /**
4491     * Sets other attributes of the TLSSocketServer connection.
4492     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
4493     * @returns { Promise<void> } The promise returned by the function.
4494     * @throws { BusinessError } 401 - Parameter error.
4495     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4496     * @throws { BusinessError } 2300002 - System internal error.
4497     * @syscap SystemCapability.Communication.NetStack
4498     * @since 10
4499     */
4500    setExtraOptions(options: TCPExtraOptions): Promise<void>;
4501
4502    /**
4503     * Returns an object representing a local certificate.
4504     * @param { AsyncCallback<X509CertRawData> } callback - The callback of getCertificate.
4505     * @throws { BusinessError } 401 - Parameter error.
4506     * @throws { BusinessError } 2303501 - SSL is null.
4507     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
4508     * @throws { BusinessError } 2300002 - System internal error.
4509     * @syscap SystemCapability.Communication.NetStack
4510     * @since 10
4511     */
4512    getCertificate(callback: AsyncCallback<X509CertRawData>): void;
4513
4514    /**
4515     * Returns an object representing a local certificate.
4516     * @returns { Promise<X509CertRawData> } The promise returned by the function.
4517     * @throws { BusinessError } 2303501 - SSL is null.
4518     * @throws { BusinessError } 2303504 - An error occurred when verifying the X.509 certificate.
4519     * @throws { BusinessError } 2300002 - System internal error.
4520     * @syscap SystemCapability.Communication.NetStack
4521     * @since 10
4522     */
4523    getCertificate(): Promise<X509CertRawData>;
4524
4525    /**
4526     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
4527     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
4528     * Server sockets or disconnected client sockets will return a value of null.
4529     * @param { AsyncCallback<string> } callback - The callback of getProtocol.
4530     * @throws { BusinessError } 401 - Parameter error.
4531     * @throws { BusinessError } 2303501 - SSL is null.
4532     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4533     * @throws { BusinessError } 2300002 - System internal error.
4534     * @syscap SystemCapability.Communication.NetStack
4535     * @since 10
4536     */
4537    getProtocol(callback: AsyncCallback<string>): void;
4538
4539    /**
4540     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
4541     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
4542     * Server sockets or disconnected client sockets will return a value of null.
4543     * @returns { Promise<string> } The promise returned by the function.
4544     * @throws { BusinessError } 2303501 - SSL is null.
4545     * @throws { BusinessError } 2303505 - An error occurred in the TLS system call.
4546     * @throws { BusinessError } 2300002 - System internal error.
4547     * @syscap SystemCapability.Communication.NetStack
4548     * @since 10
4549     */
4550    getProtocol(): Promise<string>;
4551
4552    /**
4553     * Obtains the local address of the TLSSocketServer connection.
4554     * @returns { Promise<NetAddress> } The promise returned by the function.
4555     * @throws { BusinessError } 2300002 - System internal error.
4556     * @throws { BusinessError } 2301009 - Bad file descriptor.
4557     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
4558     * @syscap SystemCapability.Communication.NetStack
4559     * @since 12
4560     */
4561    getLocalAddress(): Promise<NetAddress>;
4562
4563    /**
4564     * Listens for connect events of the TLSSocketServer connection.
4565     * @param { 'connect' } type - Indicates Event name.
4566     * @param { Callback<TLSSocketConnection> } callback - The callback of on.
4567     * @throws { BusinessError } 401 - Parameter error.
4568     * @syscap SystemCapability.Communication.NetStack
4569     * @since 10
4570     */
4571    on(type: 'connect', callback: Callback<TLSSocketConnection>): void;
4572
4573    /**
4574     * Cancels listening for connect events of the TLSSocketServer connection.
4575     * @param { 'connect' } type - Indicates Event name.
4576     * @param { Callback<TLSSocketConnection> } callback - The callback of off.
4577     * @throws { BusinessError } 401 - Parameter error.
4578     * @syscap SystemCapability.Communication.NetStack
4579     * @since 10
4580     */
4581    off(type: 'connect', callback?: Callback<TLSSocketConnection>): void;
4582
4583    /**
4584     * Listens for error events of the TLSSocketServer connection.
4585     * @param { 'error' } type - Indicates Event name.
4586     * @param { ErrorCallback } callback - The callback of on.
4587     * @throws { BusinessError } 401 - Parameter error.
4588     * @syscap SystemCapability.Communication.NetStack
4589     * @since 10
4590     */
4591    on(type: 'error', callback: ErrorCallback): void;
4592
4593    /**
4594     * Cancels listening for error events of the TLSSocketServer connection.
4595     * @param { 'error' } type - Indicates Event name.
4596     * @param { ErrorCallback } callback - The callback of off.
4597     * @throws { BusinessError } 401 - Parameter error.
4598     * @syscap SystemCapability.Communication.NetStack
4599     * @since 10
4600     */
4601    off(type: 'error', callback?: ErrorCallback): void;
4602  }
4603}
4604
4605export default socket;
4606