• 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
16import type { AsyncCallback, Callback, ErrorCallback } from './@ohos.base';
17import connection from "./@ohos.net.connection";
18import type cert from './@ohos.security.cert';
19
20/**
21 * Provides TCP and UDP Socket APIs.
22 * @namespace socket
23 * @syscap SystemCapability.Communication.NetStack
24 * @since 7
25 */
26/**
27 * Provides TCP and UDP Socket APIs.
28 * @namespace socket
29 * @syscap SystemCapability.Communication.NetStack
30 * @crossplatform
31 * @since 10
32 */
33declare namespace socket {
34  export import NetAddress = connection.NetAddress;
35  /**
36   * Deposit certificate
37   * @syscap SystemCapability.Communication.NetStack
38   * @since 9
39   */
40  /**
41   * Deposit certificate
42   * @syscap SystemCapability.Communication.NetStack
43   * @crossplatform
44   * @since 10
45   */
46  export type X509CertRawData = cert.EncodingBlob;
47
48  /**
49   * Creates a UDPSocket object.
50   * @returns { UDPSocket } the UDPSocket of the constructUDPSocketInstance.
51   * @syscap SystemCapability.Communication.NetStack
52   * @since 7
53   */
54  /**
55   * Creates a UDPSocket object.
56   * @returns { UDPSocket } the UDPSocket of the constructUDPSocketInstance.
57   * @syscap SystemCapability.Communication.NetStack
58   * @crossplatform
59   * @since 10
60   */
61  function constructUDPSocketInstance(): UDPSocket;
62
63  /**
64   * Creates a TCPSocket object.
65   * @returns { TCPSocket } the TCPSocket of the constructTCPSocketInstance.
66   * @syscap SystemCapability.Communication.NetStack
67   * @since 7
68   */
69  /**
70   * Creates a TCPSocket object.
71   * @returns { TCPSocket } the TCPSocket of the constructTCPSocketInstance.
72   * @syscap SystemCapability.Communication.NetStack
73   * @crossplatform
74   * @since 10
75   */
76  function constructTCPSocketInstance(): TCPSocket;
77
78  /**
79   * Creates a TLSSocket object.
80   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
81   * @syscap SystemCapability.Communication.NetStack
82   * @since 9
83   */
84  /**
85   * Creates a TLSSocket object.
86   * @returns { TLSSocket } the TLSSocket of the constructTLSSocketInstance.
87   * @syscap SystemCapability.Communication.NetStack
88   * @crossplatform
89   * @since 10
90   */
91  function constructTLSSocketInstance(): TLSSocket;
92
93  /**
94   * Creates a TCPSocketServer object.
95   * @returns { TCPSocketServer } the TCPSocketServer of the constructTCPSocketServerInstance.
96   * @syscap SystemCapability.Communication.NetStack
97   * @since 10
98   */
99  function constructTCPSocketServerInstance(): TCPSocketServer;
100
101  /**
102   * Creates a TLSSocketServer object.
103   * @returns { TLSSocketServer } the TLSSocketServer of the constructTLSSocketServerInstance.
104   * @syscap SystemCapability.Communication.NetStack
105   * @since 10
106   */
107  function constructTLSSocketServerInstance(): TLSSocketServer;
108
109  /**
110   * Defines the parameters for sending data over the UDPSocket connection.
111   * @interface UDPSendOptions
112   * @syscap SystemCapability.Communication.NetStack
113   * @since 7
114   */
115  /**
116   * Defines the parameters for sending data over the UDPSocket connection.
117   * @interface UDPSendOptions
118   * @syscap SystemCapability.Communication.NetStack
119   * @crossplatform
120   * @since 10
121   */
122  export interface UDPSendOptions {
123    /**
124     * Data to send.
125     * @type {string | ArrayBuffer}
126     * @syscap SystemCapability.Communication.NetStack
127     * @since 7
128     */
129    /**
130     * Data to send.
131     * @type {string | ArrayBuffer}
132     * @syscap SystemCapability.Communication.NetStack
133     * @crossplatform
134     * @since 10
135     */
136    data: string | ArrayBuffer;
137
138    /**
139     * Destination address.
140     * @type {NetAddress}
141     * @syscap SystemCapability.Communication.NetStack
142     * @since 7
143     */
144    /**
145     * Destination address.
146     * @type {NetAddress}
147     * @syscap SystemCapability.Communication.NetStack
148     * @crossplatform
149     * @since 10
150     */
151    address: NetAddress;
152  }
153
154  /**
155   * @interface ExtraOptionsBase
156   * @syscap SystemCapability.Communication.NetStack
157   * @since 7
158   */
159  /**
160   * @interface ExtraOptionsBase
161   * @syscap SystemCapability.Communication.NetStack
162   * @crossplatform
163   * @since 10
164   */
165  export interface ExtraOptionsBase {
166    /**
167     * Size of the receive buffer, in MBS.
168     * @type {?number}
169     * @syscap SystemCapability.Communication.NetStack
170     * @since 7
171     */
172    /**
173     * Size of the receive buffer, in MBS.
174     * @type {?number}
175     * @syscap SystemCapability.Communication.NetStack
176     * @crossplatform
177     * @since 10
178     */
179    receiveBufferSize?: number;
180
181    /**
182     * Size of the send buffer, in MBS.
183     * @type {?number}
184     * @syscap SystemCapability.Communication.NetStack
185     * @since 7
186     */
187    /**
188     * Size of the send buffer, in MBS.
189     * @type {?number}
190     * @syscap SystemCapability.Communication.NetStack
191     * @crossplatform
192     * @since 10
193     */
194    sendBufferSize?: number;
195
196    /**
197     * Whether to reuse addresses. The default value is false.
198     * @type {?boolean}
199     * @syscap SystemCapability.Communication.NetStack
200     * @since 7
201     */
202    /**
203     * Whether to reuse addresses. The default value is false.
204     * @type {?boolean}
205     * @syscap SystemCapability.Communication.NetStack
206     * @crossplatform
207     * @since 10
208     */
209    reuseAddress?: boolean;
210
211    /**
212     * Timeout duration of the UDPSocket connection, in milliseconds.
213     * @type {?number}
214     * @syscap SystemCapability.Communication.NetStack
215     * @since 7
216     */
217    /**
218     * Timeout duration of the UDPSocket connection, in milliseconds.
219     * @type {?number}
220     * @syscap SystemCapability.Communication.NetStack
221     * @crossplatform
222     * @since 10
223     */
224    socketTimeout?: number;
225  }
226
227  /**
228   * Defines other properties of the UDPSocket connection.
229   * @interface UDPExtraOptions
230   * @syscap SystemCapability.Communication.NetStack
231   * @since 7
232   */
233  /**
234   * Defines other properties of the UDPSocket connection.
235   * @interface UDPExtraOptions
236   * @syscap SystemCapability.Communication.NetStack
237   * @crossplatform
238   * @since 10
239   */
240  export interface UDPExtraOptions extends ExtraOptionsBase {
241    /**
242     * Whether to send broadcast messages. The default value is false.
243     * @type {?boolean}
244     * @syscap SystemCapability.Communication.NetStack
245     * @since 7
246     */
247    /**
248     * Whether to send broadcast messages. The default value is false.
249     * @type {?boolean}
250     * @syscap SystemCapability.Communication.NetStack
251     * @crossplatform
252     * @since 10
253     */
254    broadcast?: boolean;
255  }
256
257  /**
258   * Defines the status of the socket connection.
259   * @interface SocketStateBase
260   * @syscap SystemCapability.Communication.NetStack
261   * @since 7
262   */
263  /**
264   * Defines the status of the socket connection.
265   * @interface SocketStateBase
266   * @syscap SystemCapability.Communication.NetStack
267   * @crossplatform
268   * @since 10
269   */
270  export interface SocketStateBase {
271    /**
272     * Whether the connection is in the bound state.
273     * @type {boolean}
274     * @syscap SystemCapability.Communication.NetStack
275     * @since 7
276     */
277    /**
278     * Whether the connection is in the bound state.
279     * @type {boolean}
280     * @syscap SystemCapability.Communication.NetStack
281     * @crossplatform
282     * @since 10
283     */
284    isBound: boolean;
285
286    /**
287     * Whether the connection is in the closed state.
288     * @type {boolean}
289     * @syscap SystemCapability.Communication.NetStack
290     * @since 7
291     */
292    /**
293     * Whether the connection is in the closed state.
294     * @type {boolean}
295     * @syscap SystemCapability.Communication.NetStack
296     * @crossplatform
297     * @since 10
298     */
299    isClose: boolean;
300
301    /**
302     * Whether the connection is in the connected state.
303     * @type {boolean}
304     * @syscap SystemCapability.Communication.NetStack
305     * @since 7
306     */
307    /**
308     * Whether the connection is in the connected state.
309     * @type {boolean}
310     * @syscap SystemCapability.Communication.NetStack
311     * @crossplatform
312     * @since 10
313     */
314    isConnected: boolean;
315  }
316
317  /**
318   * Defines information about the socket connection.
319   * @interface SocketRemoteInfo
320   * @syscap SystemCapability.Communication.NetStack
321   * @since 7
322   */
323  /**
324   * Defines information about the socket connection.
325   * @interface SocketRemoteInfo
326   * @syscap SystemCapability.Communication.NetStack
327   * @crossplatform
328   * @since 10
329   */
330  export interface SocketRemoteInfo {
331    /**
332     * Bound IP address.
333     * @type {string}
334     * @syscap SystemCapability.Communication.NetStack
335     * @since 7
336     */
337    /**
338     * Bound IP address.
339     * @type {string}
340     * @syscap SystemCapability.Communication.NetStack
341     * @crossplatform
342     * @since 10
343     */
344    address: string;
345
346    /**
347     * Network protocol type. The options are as follows: IPv4, IPv6.
348     * @type {'IPv4' | 'IPv6'}
349     * @syscap SystemCapability.Communication.NetStack
350     * @since 7
351     */
352    /**
353     * Network protocol type. The options are as follows: IPv4, IPv6.
354     * @type {'IPv4' | 'IPv6'}
355     * @syscap SystemCapability.Communication.NetStack
356     * @crossplatform
357     * @since 10
358     */
359    family: 'IPv4' | 'IPv6';
360
361    /**
362     * Port number. The value ranges from 0 to 65535.
363     * @type {number}
364     * @syscap SystemCapability.Communication.NetStack
365     * @since 7
366     */
367    /**
368     * Port number. The value ranges from 0 to 65535.
369     * @type {number}
370     * @syscap SystemCapability.Communication.NetStack
371     * @crossplatform
372     * @since 10
373     */
374    port: number;
375
376    /**
377     * Length of the server response message, in bytes.
378     * @type {number}
379     * @syscap SystemCapability.Communication.NetStack
380     * @since 7
381     */
382    /**
383     * Length of the server response message, in bytes.
384     * @type {number}
385     * @syscap SystemCapability.Communication.NetStack
386     * @crossplatform
387     * @since 10
388     */
389    size: number;
390  }
391
392  /**
393   * Defines a UDPSocket connection.
394   * @interface UDPSocket
395   * @syscap SystemCapability.Communication.NetStack
396   * @since 7
397   */
398  /**
399   * Defines a UDPSocket connection.
400   * @interface UDPSocket
401   * @syscap SystemCapability.Communication.NetStack
402   * @crossplatform
403   * @since 10
404   */
405  export interface UDPSocket {
406    /**
407     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
408     * @permission ohos.permission.INTERNET
409     * @param { NetAddress } address - Destination address. {@link NetAddress}
410     * @param { AsyncCallback<void> } callback - the callback of bind.
411     * @throws { BusinessError } 401 - Parameter error.
412     * @throws { BusinessError } 201 - Permission denied.
413     * @syscap SystemCapability.Communication.NetStack
414     * @since 7
415     */
416    /**
417     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
418     * @permission ohos.permission.INTERNET
419     * @param { NetAddress } address - Destination address. {@link NetAddress}
420     * @param { AsyncCallback<void> } callback - the callback of bind.
421     * @throws { BusinessError } 401 - Parameter error.
422     * @throws { BusinessError } 201 - Permission denied.
423     * @syscap SystemCapability.Communication.NetStack
424     * @crossplatform
425     * @since 10
426     */
427    bind(address: NetAddress, callback: AsyncCallback<void>): void;
428
429    /**
430     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
431     * @permission ohos.permission.INTERNET
432     * @param { NetAddress } address - Destination address. {@link NetAddress}
433     * @returns { Promise<void> } The promise returned by the function.
434     * @throws { BusinessError } 401 - Parameter error.
435     * @throws { BusinessError } 201 - Permission denied.
436     * @syscap SystemCapability.Communication.NetStack
437     * @since 7
438     */
439    /**
440     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
441     * @permission ohos.permission.INTERNET
442     * @param { NetAddress } address - Destination address. {@link NetAddress}
443     * @returns { Promise<void> } The promise returned by the function.
444     * @throws { BusinessError } 401 - Parameter error.
445     * @throws { BusinessError } 201 - Permission denied.
446     * @syscap SystemCapability.Communication.NetStack
447     * @crossplatform
448     * @since 10
449     */
450    bind(address: NetAddress): Promise<void>;
451
452    /**
453     * Sends data over a UDPSocket connection.
454     * @permission ohos.permission.INTERNET
455     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
456     * @param { AsyncCallback<void> } callback - the callback of send.
457     * @throws { BusinessError } 401 - Parameter error.
458     * @throws { BusinessError } 201 - Permission denied.
459     * @syscap SystemCapability.Communication.NetStack
460     * @since 7
461     */
462    /**
463     * Sends data over a UDPSocket connection.
464     * @permission ohos.permission.INTERNET
465     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
466     * @param { AsyncCallback<void> } callback - the callback of send.
467     * @throws { BusinessError } 401 - Parameter error.
468     * @throws { BusinessError } 201 - Permission denied.
469     * @syscap SystemCapability.Communication.NetStack
470     * @crossplatform
471     * @since 10
472     */
473    send(options: UDPSendOptions, callback: AsyncCallback<void>): void;
474
475    /**
476     * Sends data over a UDPSocket connection.
477     * @permission ohos.permission.INTERNET
478     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
479     * @returns { Promise<void> } The promise returned by the function.
480     * @throws { BusinessError } 401 - Parameter error.
481     * @throws { BusinessError } 201 - Permission denied.
482     * @syscap SystemCapability.Communication.NetStack
483     * @since 7
484     */
485    /**
486     * Sends data over a UDPSocket connection.
487     * @permission ohos.permission.INTERNET
488     * @param { UDPSendOptions } options - Optional parameters {@link UDPSendOptions}.
489     * @returns { Promise<void> } The promise returned by the function.
490     * @throws { BusinessError } 401 - Parameter error.
491     * @throws { BusinessError } 201 - Permission denied.
492     * @syscap SystemCapability.Communication.NetStack
493     * @crossplatform
494     * @since 10
495     */
496    send(options: UDPSendOptions): Promise<void>;
497
498    /**
499     * Closes a UDPSocket connection.
500     * @permission ohos.permission.INTERNET
501     * @param { AsyncCallback<void> } callback - the callback of close.
502     * @throws { BusinessError } 201 - Permission denied.
503     * @syscap SystemCapability.Communication.NetStack
504     * @since 7
505     */
506    /**
507     * Closes a UDPSocket connection.
508     * @permission ohos.permission.INTERNET
509     * @param { AsyncCallback<void> } callback - the callback of close.
510     * @throws { BusinessError } 201 - Permission denied.
511     * @syscap SystemCapability.Communication.NetStack
512     * @crossplatform
513     * @since 10
514     */
515    close(callback: AsyncCallback<void>): void;
516
517    /**
518     * Closes a UDPSocket connection.
519     * @permission ohos.permission.INTERNET
520     * @returns { Promise<void> } The promise returned by the function.
521     * @throws { BusinessError } 201 - Permission denied.
522     * @syscap SystemCapability.Communication.NetStack
523     * @since 7
524     */
525    /**
526     * Closes a UDPSocket connection.
527     * @permission ohos.permission.INTERNET
528     * @returns { Promise<void> } The promise returned by the function.
529     * @throws { BusinessError } 201 - Permission denied.
530     * @syscap SystemCapability.Communication.NetStack
531     * @crossplatform
532     * @since 10
533     */
534    close(): Promise<void>;
535
536    /**
537     * Obtains the status of the UDPSocket connection.
538     * @permission ohos.permission.INTERNET
539     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}.
540     * @throws { BusinessError } 201 - Permission denied.
541     * @syscap SystemCapability.Communication.NetStack
542     * @since 7
543     */
544    /**
545     * Obtains the status of the UDPSocket connection.
546     * @permission ohos.permission.INTERNET
547     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}.
548     * @throws { BusinessError } 201 - Permission denied.
549     * @syscap SystemCapability.Communication.NetStack
550     * @crossplatform
551     * @since 10
552     */
553    getState(callback: AsyncCallback<SocketStateBase>): void;
554
555    /**
556     * Obtains the status of the UDPSocket connection.
557     * @permission ohos.permission.INTERNET
558     * @returns { Promise<SocketStateBase> } The promise returned by the function.
559     * @throws { BusinessError } 201 - Permission denied.
560     * @syscap SystemCapability.Communication.NetStack
561     * @since 7
562     */
563    /**
564     * Obtains the status of the UDPSocket connection.
565     * @permission ohos.permission.INTERNET
566     * @returns { Promise<SocketStateBase> } The promise returned by the function.
567     * @throws { BusinessError } 201 - Permission denied.
568     * @syscap SystemCapability.Communication.NetStack
569     * @crossplatform
570     * @since 10
571     */
572    getState(): Promise<SocketStateBase>;
573
574    /**
575     * Sets other attributes of the UDPSocket connection.
576     * @permission ohos.permission.INTERNET
577     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
578     * @param { AsyncCallback<void> }callback - the callback of setExtraOptions.
579     * @throws { BusinessError } 401 - Parameter error.
580     * @throws { BusinessError } 201 - Permission denied.
581     * @syscap SystemCapability.Communication.NetStack
582     * @since 7
583     */
584    /**
585     * Sets other attributes of the UDPSocket connection.
586     * @permission ohos.permission.INTERNET
587     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
588     * @param { AsyncCallback<void> }callback - the callback of setExtraOptions.
589     * @throws { BusinessError } 401 - Parameter error.
590     * @throws { BusinessError } 201 - Permission denied.
591     * @syscap SystemCapability.Communication.NetStack
592     * @crossplatform
593     * @since 10
594     */
595    setExtraOptions(options: UDPExtraOptions, callback: AsyncCallback<void>): void;
596
597    /**
598     * Sets other attributes of the UDPSocket connection.
599     * @permission ohos.permission.INTERNET
600     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
601     * @returns { Promise<void> } The promise returned by the function.
602     * @throws { BusinessError } 401 - Parameter error.
603     * @throws { BusinessError } 201 - Permission denied.
604     * @syscap SystemCapability.Communication.NetStack
605     * @since 7
606     */
607    /**
608     * Sets other attributes of the UDPSocket connection.
609     * @permission ohos.permission.INTERNET
610     * @param { UDPExtraOptions } options - Optional parameters {@link UDPExtraOptions}.
611     * @returns { Promise<void> } The promise returned by the function.
612     * @throws { BusinessError } 401 - Parameter error.
613     * @throws { BusinessError } 201 - Permission denied.
614     * @syscap SystemCapability.Communication.NetStack
615     * @crossplatform
616     * @since 10
617     */
618    setExtraOptions(options: UDPExtraOptions): Promise<void>;
619
620    /**
621     * Listens for message receiving events of the UDPSocket connection.
622     * @param { 'message' } type - Indicates Event name.
623     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
624     * @syscap SystemCapability.Communication.NetStack
625     * @since 7
626     */
627    /**
628     * Listens for message receiving events of the UDPSocket connection.
629     * @param { 'message' } type - Indicates Event name.
630     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
631     * @syscap SystemCapability.Communication.NetStack
632     * @crossplatform
633     * @since 10
634     */
635    on(type: 'message', callback: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
636
637    /**
638     * Cancels listening for message receiving events of the UDPSocket connection.
639     * @param { 'message' } type - Indicates Event name.
640     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
641     * @syscap SystemCapability.Communication.NetStack
642     * @since 7
643     */
644    /**
645     * Cancels listening for message receiving events of the UDPSocket connection.
646     * @param { 'message' } type - Indicates Event name.
647     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
648     * @syscap SystemCapability.Communication.NetStack
649     * @crossplatform
650     * @since 10
651     */
652    off(type: 'message', callback?: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
653
654    /**
655     * Listens for data packet message events or close events of the UDPSocket connection.
656     * @param { 'listening' | 'close' } type - Indicates Event name.
657     * @param { Callback<void> } callback - the callback used to return the result.
658     * @syscap SystemCapability.Communication.NetStack
659     * @since 7
660     */
661    /**
662     * Listens for data packet message events or close events of the UDPSocket connection.
663     * @param { 'listening' | 'close' } type - Indicates Event name.
664     * @param { Callback<void> } callback - the callback used to return the result.
665     * @syscap SystemCapability.Communication.NetStack
666     * @crossplatform
667     * @since 10
668     */
669    on(type: 'listening' | 'close', callback: Callback<void>): void;
670
671    /**
672     * Cancels listening for data packet message events or close events of the UDPSocket connection.
673     * @param { 'listening' | 'close' } type - Indicates Event name.
674     * @param { Callback<void> } callback - the callback used to return the result.
675     * @syscap SystemCapability.Communication.NetStack
676     * @since 7
677     */
678    /**
679     * Cancels listening for data packet message events or close events of the UDPSocket connection.
680     * @param { 'listening' | 'close' } type - Indicates Event name.
681     * @param { Callback<void> } callback - the callback used to return the result.
682     * @syscap SystemCapability.Communication.NetStack
683     * @crossplatform
684     * @since 10
685     */
686    off(type: 'listening' | 'close', callback?: Callback<void>): void;
687
688    /**
689     * Listens for error events of the UDPSocket connection.
690     * @param { 'error' } type - Indicates Event name.
691     * @param { ErrorCallback } callback - the callback used to return the result.
692     * @syscap SystemCapability.Communication.NetStack
693     * @since 7
694     */
695    /**
696     * Listens for error events of the UDPSocket connection.
697     * @param { 'error' } type - Indicates Event name.
698     * @param { ErrorCallback } callback - the callback used to return the result.
699     * @syscap SystemCapability.Communication.NetStack
700     * @crossplatform
701     * @since 10
702     */
703    on(type: 'error', callback: ErrorCallback): void;
704
705    /**
706     * Cancels listening for error events of the UDPSocket connection.
707     * @param { 'error' } type - Indicates Event name.
708     * @param { ErrorCallback } callback - the callback used to return the result.
709     * @syscap SystemCapability.Communication.NetStack
710     * @since 7
711     */
712    /**
713     * Cancels listening for error events of the UDPSocket connection.
714     * @param { 'error' } type - Indicates Event name.
715     * @param { ErrorCallback } callback - the callback used to return the result.
716     * @syscap SystemCapability.Communication.NetStack
717     * @crossplatform
718     * @since 10
719     */
720    off(type: 'error', callback?: ErrorCallback): void;
721  }
722
723  /**
724   * Defines TCPSocket connection parameters.
725   * @interface TCPConnectOptions
726   * @syscap SystemCapability.Communication.NetStack
727   * @since 7
728   */
729  /**
730   * Defines TCPSocket connection parameters.
731   * @interface TCPConnectOptions
732   * @syscap SystemCapability.Communication.NetStack
733   * @crossplatform
734   * @since 10
735   */
736  export interface TCPConnectOptions {
737    /**
738     * Bound IP address and port number.
739     * @type { NetAddress }
740     * @syscap SystemCapability.Communication.NetStack
741     * @since 7
742     */
743    /**
744     * Bound IP address and port number.
745     * @type { NetAddress }
746     * @syscap SystemCapability.Communication.NetStack
747     * @crossplatform
748     * @since 10
749     */
750    address: NetAddress;
751
752    /**
753     * Timeout duration of the TCPSocket connection, in milliseconds.
754     * @type { ?number }
755     * @syscap SystemCapability.Communication.NetStack
756     * @since 7
757     */
758    /**
759     * Timeout duration of the TCPSocket connection, in milliseconds.
760     * @type { ?number }
761     * @syscap SystemCapability.Communication.NetStack
762     * @crossplatform
763     * @since 10
764     */
765    timeout?: number;
766  }
767
768  /**
769   * Defines the parameters for sending data over the TCPSocket connection.
770   * @interface TCPSendOptions
771   * @syscap SystemCapability.Communication.NetStack
772   * @since 7
773   */
774  /**
775   * Defines the parameters for sending data over the TCPSocket connection.
776   * @interface TCPSendOptions
777   * @syscap SystemCapability.Communication.NetStack
778   * @crossplatform
779   * @since 10
780   */
781  export interface TCPSendOptions {
782    /**
783     * Data to send.
784     * @type { string | ArrayBuffer }
785     * @syscap SystemCapability.Communication.NetStack
786     * @since 7
787     */
788    /**
789     * Data to send.
790     * @type { string | ArrayBuffer }
791     * @syscap SystemCapability.Communication.NetStack
792     * @crossplatform
793     * @since 10
794     */
795    data: string | ArrayBuffer;
796
797    /**
798     * Character encoding format.
799     * @type { ?string }
800     * @syscap SystemCapability.Communication.NetStack
801     * @since 7
802     */
803    /**
804     * Character encoding format.
805     * @type { ?string }
806     * @syscap SystemCapability.Communication.NetStack
807     * @crossplatform
808     * @since 10
809     */
810    encoding?: string;
811  }
812
813  /**
814   * Defines other properties of the TCPSocket connection.
815   * @interface TCPExtraOptions
816   * @syscap SystemCapability.Communication.NetStack
817   * @since 7
818   */
819  /**
820   * Defines other properties of the TCPSocket connection.
821   * @interface TCPExtraOptions
822   * @syscap SystemCapability.Communication.NetStack
823   * @crossplatform
824   * @since 10
825   */
826  export interface TCPExtraOptions extends ExtraOptionsBase {
827    /**
828     * Whether to keep the connection alive. The default value is false.
829     * @type { ?boolean }
830     * @syscap SystemCapability.Communication.NetStack
831     * @since 7
832     */
833    /**
834     * Whether to keep the connection alive. The default value is false.
835     * @type { ?boolean }
836     * @syscap SystemCapability.Communication.NetStack
837     * @crossplatform
838     * @since 10
839     */
840    keepAlive?: boolean;
841
842    /**
843     * Whether to enable OOBInline. The default value is false.
844     * @type { ?boolean }
845     * @syscap SystemCapability.Communication.NetStack
846     * @since 7
847     */
848    /**
849     * Whether to enable OOBInline. The default value is false.
850     * @type { ?boolean }
851     * @syscap SystemCapability.Communication.NetStack
852     * @crossplatform
853     * @since 10
854     */
855    OOBInline?: boolean;
856
857    /**
858     * Whether to enable no-delay on the TCPSocket connection. The default value is false.
859     * @type { ?boolean }
860     * @syscap SystemCapability.Communication.NetStack
861     * @since 7
862     */
863    /**
864     * Whether to enable no-delay on the TCPSocket connection. The default value is false.
865     * @type { ?boolean }
866     * @syscap SystemCapability.Communication.NetStack
867     * @crossplatform
868     * @since 10
869     */
870    TCPNoDelay?: boolean;
871
872    /**
873     * Socket linger.
874     * @type { ?object }
875     * @syscap SystemCapability.Communication.NetStack
876     * @crossplatform
877     * @since 7
878     */
879    /**
880     * Socket linger.
881     * @type { ?object }
882     * @syscap SystemCapability.Communication.NetStack
883     * @crossplatform
884     * @since 10
885     */
886    socketLinger?: { on: boolean, linger: number };
887  }
888
889  /**
890   * Defines a TCPSocket connection.
891   * @interface TCPSocket
892   * @syscap SystemCapability.Communication.NetStack
893   * @since 7
894   */
895  /**
896   * Defines a TCPSocket connection.
897   * @interface TCPSocket
898   * @syscap SystemCapability.Communication.NetStack
899   * @crossplatform
900   * @since 10
901   */
902  export interface TCPSocket {
903    /**
904     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
905     * @permission ohos.permission.INTERNET
906     * @param { NetAddress } address - Destination address. {@link NetAddress}
907     * @param { AsyncCallback<void> } callback - Return the callback of bind.
908     * @throws { BusinessError } 401 - Parameter error.
909     * @throws { BusinessError } 201 - Permission denied.
910     * @syscap SystemCapability.Communication.NetStack
911     * @since 7
912     */
913    /**
914     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
915     * @permission ohos.permission.INTERNET
916     * @param { NetAddress } address - Destination address. {@link NetAddress}
917     * @param { AsyncCallback<void> } callback - the callback of bind.
918     * @throws { BusinessError } 401 - Parameter error.
919     * @throws { BusinessError } 201 - Permission denied.
920     * @syscap SystemCapability.Communication.NetStack
921     * @crossplatform
922     * @since 10
923     */
924    bind(address: NetAddress, callback: AsyncCallback<void>): void;
925
926    /**
927     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
928     * @permission ohos.permission.INTERNET
929     * @param { NetAddress } address - Destination address. {@link NetAddress}
930     * @returns { Promise<void> } The promise returned by the function.
931     * @throws { BusinessError } 401 - Parameter error.
932     * @throws { BusinessError } 201 - Permission denied.
933     * @syscap SystemCapability.Communication.NetStack
934     * @since 7
935     */
936    /**
937     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
938     * @permission ohos.permission.INTERNET
939     * @param { NetAddress } address - Destination address. {@link NetAddress}
940     * @returns { Promise<void> } The promise returned by the function.
941     * @throws { BusinessError } 401 - Parameter error.
942     * @throws { BusinessError } 201 - Permission denied.
943     * @syscap SystemCapability.Communication.NetStack
944     * @crossplatform
945     * @since 10
946     */
947    bind(address: NetAddress): Promise<void>;
948
949    /**
950     * Sets up a connection to the specified IP address and port number.
951     * @permission ohos.permission.INTERNET
952     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
953     * @param { AsyncCallback<void> } callback - the callback of connect.
954     * @throws { BusinessError } 401 - Parameter error.
955     * @throws { BusinessError } 201 - Permission denied.
956     * @syscap SystemCapability.Communication.NetStack
957     * @since 7
958     */
959    /**
960     * Sets up a connection to the specified IP address and port number.
961     * @permission ohos.permission.INTERNET
962     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
963     * @param { AsyncCallback<void> } callback - the callback of connect.
964     * @throws { BusinessError } 401 - Parameter error.
965     * @throws { BusinessError } 201 - Permission denied.
966     * @syscap SystemCapability.Communication.NetStack
967     * @crossplatform
968     * @since 10
969     */
970    connect(options: TCPConnectOptions, callback: AsyncCallback<void>): void;
971
972    /**
973     * Sets up a connection to the specified IP address and port number.
974     * @permission ohos.permission.INTERNET
975     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
976     * @returns { Promise<void> } The promise returned by the function.
977     * @throws { BusinessError } 401 - Parameter error.
978     * @throws { BusinessError } 201 - Permission denied.
979     * @syscap SystemCapability.Communication.NetStack
980     * @since 7
981     */
982    /**
983     * Sets up a connection to the specified IP address and port number.
984     * @permission ohos.permission.INTERNET
985     * @param { TCPConnectOptions } options - Optional parameters {@link TCPConnectOptions}.
986     * @returns { Promise<void> } The promise returned by the function.
987     * @throws { BusinessError } 401 - Parameter error.
988     * @throws { BusinessError } 201 - Permission denied.
989     * @syscap SystemCapability.Communication.NetStack
990     * @crossplatform
991     * @since 10
992     */
993    connect(options: TCPConnectOptions): Promise<void>;
994
995    /**
996     * Sends data over a TCPSocket connection.
997     * @permission ohos.permission.INTERNET
998     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
999     * @param { AsyncCallback<void> } callback - the callback of send.
1000     * @throws { BusinessError } 401 - Parameter error.
1001     * @throws { BusinessError } 201 - Permission denied.
1002     * @syscap SystemCapability.Communication.NetStack
1003     * @since 7
1004     */
1005    /**
1006     * Sends data over a TCPSocket connection.
1007     * @permission ohos.permission.INTERNET
1008     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
1009     * @param { AsyncCallback<void> } callback - the callback of send.
1010     * @throws { BusinessError } 401 - Parameter error.
1011     * @throws { BusinessError } 201 - Permission denied.
1012     * @syscap SystemCapability.Communication.NetStack
1013     * @crossplatform
1014     * @since 10
1015     */
1016    send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
1017
1018    /**
1019     * Sends data over a TCPSocket connection.
1020     * @permission ohos.permission.INTERNET
1021     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
1022     * @returns { Promise<void> } The promise returned by the function.
1023     * @throws { BusinessError } 401 - Parameter error.
1024     * @throws { BusinessError } 201 - Permission denied.
1025     * @syscap SystemCapability.Communication.NetStack
1026     * @since 7
1027     */
1028    /**
1029     * Sends data over a TCPSocket connection.
1030     * @permission ohos.permission.INTERNET
1031     * @param { TCPSendOptions } options - Optional parameters {@link TCPSendOptions}.
1032     * @returns { Promise<void> } The promise returned by the function.
1033     * @throws { BusinessError } 401 - Parameter error.
1034     * @throws { BusinessError } 201 - Permission denied.
1035     * @syscap SystemCapability.Communication.NetStack
1036     * @crossplatform
1037     * @since 10
1038     */
1039    send(options: TCPSendOptions): Promise<void>;
1040
1041    /**
1042     * Closes a TCPSocket connection.
1043     * @permission ohos.permission.INTERNET
1044     * @param { AsyncCallback<void> } callback - the callback of close.
1045     * @throws { BusinessError } 201 - Permission denied.
1046     * @syscap SystemCapability.Communication.NetStack
1047     * @since 7
1048     */
1049    /**
1050     * Closes a TCPSocket connection.
1051     * @permission ohos.permission.INTERNET
1052     * @param { AsyncCallback<void> } callback - the callback of close.
1053     * @throws { BusinessError } 201 - Permission denied.
1054     * @syscap SystemCapability.Communication.NetStack
1055     * @crossplatform
1056     * @since 10
1057     */
1058    close(callback: AsyncCallback<void>): void;
1059
1060    /**
1061     * Closes a TCPSocket connection.
1062     * @permission ohos.permission.INTERNET
1063     * @returns { Promise<void> } The promise returned by the function.
1064     * @throws { BusinessError } 201 - Permission denied.
1065     * @syscap SystemCapability.Communication.NetStack
1066     * @since 7
1067     */
1068    /**
1069     * Closes a TCPSocket connection.
1070     * @permission ohos.permission.INTERNET
1071     * @returns { Promise<void> } The promise returned by the function.
1072     * @throws { BusinessError } 201 - Permission denied.
1073     * @syscap SystemCapability.Communication.NetStack
1074     * @crossplatform
1075     * @since 10
1076     */
1077    close(): Promise<void>;
1078
1079    /**
1080     * Obtains the peer address of a TCPSocket connection.
1081     * @permission ohos.permission.INTERNET
1082     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress. {@link NetAddress}
1083     * @throws { BusinessError } 201 - Permission denied.
1084     * @syscap SystemCapability.Communication.NetStack
1085     * @since 7
1086     */
1087    /**
1088     * Obtains the peer address of a TCPSocket connection.
1089     * @permission ohos.permission.INTERNET
1090     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress. {@link NetAddress}
1091     * @throws { BusinessError } 201 - Permission denied.
1092     * @syscap SystemCapability.Communication.NetStack
1093     * @crossplatform
1094     * @since 10
1095     */
1096    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
1097
1098    /**
1099     * Obtains the peer address of a TCPSocket connection.
1100     * @permission ohos.permission.INTERNET
1101     * @returns { Promise<NetAddress> } The promise returned by the function.
1102     * @throws { BusinessError } 201 - Permission denied.
1103     * @syscap SystemCapability.Communication.NetStack
1104     * @since 7
1105     */
1106    /**
1107     * Obtains the peer address of a TCPSocket connection.
1108     * @permission ohos.permission.INTERNET
1109     * @returns { Promise<NetAddress> } The promise returned by the function.
1110     * @throws { BusinessError } 201 - Permission denied.
1111     * @syscap SystemCapability.Communication.NetStack
1112     * @crossplatform
1113     * @since 10
1114     */
1115    getRemoteAddress(): Promise<NetAddress>;
1116
1117    /**
1118     * Obtains the status of the TCPSocket connection.
1119     * @permission ohos.permission.INTERNET
1120     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}
1121     * @throws { BusinessError } 201 - Permission denied.
1122     * @syscap SystemCapability.Communication.NetStack
1123     * @since 7
1124     */
1125    /**
1126     * Obtains the status of the TCPSocket connection.
1127     * @permission ohos.permission.INTERNET
1128     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState. {@link SocketStateBase}
1129     * @throws { BusinessError } 201 - Permission denied.
1130     * @syscap SystemCapability.Communication.NetStack
1131     * @crossplatform
1132     * @since 10
1133     */
1134    getState(callback: AsyncCallback<SocketStateBase>): void;
1135
1136    /**
1137     * Obtains the status of the TCPSocket connection.
1138     * @permission ohos.permission.INTERNET
1139     * @returns { Promise<SocketStateBase> } The promise returned by the function.
1140     * @throws { BusinessError } 201 - Permission denied.
1141     * @syscap SystemCapability.Communication.NetStack
1142     * @since 7
1143     */
1144    /**
1145     * Obtains the status of the TCPSocket connection.
1146     * @permission ohos.permission.INTERNET
1147     * @returns { Promise<SocketStateBase> } The promise returned by the function.
1148     * @throws { BusinessError } 201 - Permission denied.
1149     * @syscap SystemCapability.Communication.NetStack
1150     * @crossplatform
1151     * @since 10
1152     */
1153    getState(): Promise<SocketStateBase>;
1154
1155    /**
1156     * Obtains the file descriptor of the TCPSocket connection.
1157     * @param { AsyncCallback<number> } callback - The callback returns the file descriptor of the TCPSocket connection.
1158     * @syscap SystemCapability.Communication.NetStack
1159     * @since 10
1160     */
1161    getSocketFd(callback: AsyncCallback<number>): void;
1162
1163    /**
1164     * Obtains the file descriptor of the TCPSocket connection.
1165     * @returns { Promise<number> } The promise returns the file descriptor of the TCPSocket connection.
1166     * @syscap SystemCapability.Communication.NetStack
1167     * @since 10
1168     */
1169    getSocketFd(): Promise<number>;
1170
1171    /**
1172     * Sets other attributes of the TCPSocket connection.
1173     * @permission ohos.permission.INTERNET
1174     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
1175     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
1176     * @throws { BusinessError } 401 - Parameter error.
1177     * @throws { BusinessError } 201 - Permission denied.
1178     * @syscap SystemCapability.Communication.NetStack
1179     * @since 7
1180     */
1181    /**
1182     * Sets other attributes of the TCPSocket connection.
1183     * @permission ohos.permission.INTERNET
1184     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
1185     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
1186     * @throws { BusinessError } 401 - Parameter error.
1187     * @throws { BusinessError } 201 - Permission denied.
1188     * @syscap SystemCapability.Communication.NetStack
1189     * @crossplatform
1190     * @since 10
1191     */
1192    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
1193
1194    /**
1195     * Sets other attributes of the TCPSocket connection.
1196     * @permission ohos.permission.INTERNET
1197     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
1198     * @returns { Promise<void> } The promise returned by the function.
1199     * @throws { BusinessError } 401 - Parameter error.
1200     * @throws { BusinessError } 201 - Permission denied.
1201     * @syscap SystemCapability.Communication.NetStack
1202     * @since 7
1203     */
1204    /**
1205     * Sets other attributes of the TCPSocket connection.
1206     * @permission ohos.permission.INTERNET
1207     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
1208     * @returns { Promise<void> } The promise returned by the function.
1209     * @throws { BusinessError } 401 - Parameter error.
1210     * @throws { BusinessError } 201 - Permission denied.
1211     * @syscap SystemCapability.Communication.NetStack
1212     * @crossplatform
1213     * @since 10
1214     */
1215    setExtraOptions(options: TCPExtraOptions): Promise<void>;
1216
1217    /**
1218     * Listens for message receiving events of the TCPSocket connection.
1219     * @param { 'message' } type - Indicates Event name.
1220     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
1221     * @syscap SystemCapability.Communication.NetStack
1222     * @since 7
1223     */
1224    /**
1225     * Listens for message receiving events of the TCPSocket connection.
1226     * @param { 'message' } type Indicates Event name.
1227     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
1228     * @syscap SystemCapability.Communication.NetStack
1229     * @crossplatform
1230     * @since 10
1231     */
1232    on(type: 'message', callback: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
1233
1234    /**
1235     * Cancels listening for message receiving events of the TCPSocket connection.
1236     * @param { 'message' } type Indicates Event name.
1237     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
1238     * @syscap SystemCapability.Communication.NetStack
1239     * @since 7
1240     */
1241    /**
1242     * Cancels listening for message receiving events of the TCPSocket connection.
1243     * @param { 'message' } type Indicates Event name.
1244     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
1245     * @syscap SystemCapability.Communication.NetStack
1246     * @crossplatform
1247     * @since 10
1248     */
1249    off(type: 'message', callback?: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
1250
1251
1252    /**
1253     * Listens for connection or close events of the TCPSocket connection.
1254     * @param { 'connect' | 'close' } type - Indicates Event name.
1255     * @param { Callback<void> } callback - the callback used to return the result.
1256     * @syscap SystemCapability.Communication.NetStack
1257     * @since 7
1258     */
1259    /**
1260     * Listens for connection or close events of the TCPSocket connection.
1261     * @param { 'connect' | 'close' } type - Indicates Event name.
1262     * @param { Callback<void> } callback - the callback used to return the result.
1263     * @syscap SystemCapability.Communication.NetStack
1264     * @crossplatform
1265     * @since 10
1266     */
1267    on(type: 'connect' | 'close', callback: Callback<void>): void;
1268
1269    /**
1270     * Cancels listening for connection or close events of the TCPSocket connection.
1271     * @param { 'connect' | 'close' } type - Indicates Event name.
1272     * @param { Callback<void> } callback - the callback used to return the result.
1273     * @syscap SystemCapability.Communication.NetStack
1274     * @since 7
1275     */
1276    /**
1277     * Cancels listening for connection or close events of the TCPSocket connection.
1278     * @param { 'connect' | 'close' } type - Indicates Event name.
1279     * @param { Callback<void> } callback - the callback used to return the result.
1280     * @syscap SystemCapability.Communication.NetStack
1281     * @crossplatform
1282     * @since 10
1283     */
1284    off(type: 'connect' | 'close', callback?: Callback<void>): void;
1285
1286    /**
1287     * Listens for error events of the TCPSocket connection.
1288     * @param { 'error' } type - Indicates Event name.
1289     * @param { ErrorCallback } callback - the callback used to return the result.
1290     * @syscap SystemCapability.Communication.NetStack
1291     * @since 7
1292     */
1293    /**
1294     * Listens for error events of the TCPSocket connection.
1295     * @param { 'error' } type - Indicates Event name.
1296     * @param { ErrorCallback } callback - the callback used to return the result.
1297     * @syscap SystemCapability.Communication.NetStack
1298     * @crossplatform
1299     * @since 10
1300     */
1301    on(type: 'error', callback: ErrorCallback): void;
1302
1303    /**
1304     * Cancels listening for error events of the TCPSocket connection.
1305     * @param { 'error' } type - Indicates Event name.
1306     * @param { ErrorCallback } callback - the callback used to return the result.
1307     * @syscap SystemCapability.Communication.NetStack
1308     * @since 7
1309     */
1310    /**
1311     * Cancels listening for error events of the TCPSocket connection.
1312     * @param { 'error' } type - Indicates Event name.
1313     * @param { ErrorCallback } callback - the callback used to return the result.
1314     * @syscap SystemCapability.Communication.NetStack
1315     * @crossplatform
1316     * @since 10
1317     */
1318    off(type: 'error', callback?: ErrorCallback): void;
1319  }
1320
1321  /**
1322   * Defines a TLSSocket connection.
1323   * @interface TLSSocket
1324   * @syscap SystemCapability.Communication.NetStack
1325   * @since 9
1326   */
1327  /**
1328   * Defines a TLSSocket connection.
1329   * @interface TLSSocket
1330   * @syscap SystemCapability.Communication.NetStack
1331   * @crossplatform
1332   * @since 10
1333   */
1334  export interface TLSSocket {
1335    /**
1336     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
1337     * @permission ohos.permission.INTERNET
1338     * @param { NetAddress } address - Destination address. {@link NetAddress}
1339     * @param { AsyncCallback<void> } callback - the callback of bind.
1340     * @throws { BusinessError } 401 - Parameter error.
1341     * @throws { BusinessError } 201 - Permission denied.
1342     * @throws { BusinessError } 2303198 - Address already in use.
1343     * @throws { BusinessError } 2300002 - System internal error.
1344     * @syscap SystemCapability.Communication.NetStack
1345     * @since 9
1346     */
1347    /**
1348     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
1349     * @permission ohos.permission.INTERNET
1350     * @param { NetAddress } address - Destination address. {@link NetAddress}
1351     * @param { AsyncCallback<void> } callback - the callback of bind.
1352     * @throws { BusinessError } 401 - Parameter error.
1353     * @throws { BusinessError } 201 - Permission denied.
1354     * @throws { BusinessError } 2303198 - Address already in use.
1355     * @throws { BusinessError } 2300002 - System internal error.
1356     * @syscap SystemCapability.Communication.NetStack
1357     * @crossplatform
1358     * @since 10
1359     */
1360    bind(address: NetAddress, callback: AsyncCallback<void>): void;
1361
1362    /**
1363     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
1364     * @permission ohos.permission.INTERNET
1365     * @param { NetAddress } address - Destination address. {@link NetAddress}
1366     * @returns { Promise<void> } The promise returned by the function.
1367     * @throws { BusinessError } 401 - Parameter error.
1368     * @throws { BusinessError } 201 - Permission denied.
1369     * @throws { BusinessError } 2303198 - Address already in use.
1370     * @throws { BusinessError } 2300002 - System internal error.
1371     * @syscap SystemCapability.Communication.NetStack
1372     * @since 9
1373     */
1374    /**
1375     * Binds the IP address and port number. The port number can be specified or randomly allocated by the system.
1376     * @permission ohos.permission.INTERNET
1377     * @param { NetAddress } address - Destination address. {@link NetAddress}
1378     * @returns { Promise<void> } The promise returned by the function.
1379     * @throws { BusinessError } 401 - Parameter error.
1380     * @throws { BusinessError } 201 - Permission denied.
1381     * @throws { BusinessError } 2303198 - Address already in use.
1382     * @throws { BusinessError } 2300002 - System internal error.
1383     * @syscap SystemCapability.Communication.NetStack
1384     * @crossplatform
1385     * @since 10
1386     */
1387    bind(address: NetAddress): Promise<void>;
1388
1389    /**
1390     * Obtains the peer address of a TLSSocket connection.
1391     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress.
1392     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1393     * @throws { BusinessError } 2300002 - System internal error.
1394     * @syscap SystemCapability.Communication.NetStack
1395     * @since 9
1396     */
1397    /**
1398     * Obtains the peer address of a TLSSocket connection.
1399     * @param { AsyncCallback<NetAddress> } callback - the callback of getRemoteAddress.
1400     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1401     * @throws { BusinessError } 2300002 - System internal error.
1402     * @syscap SystemCapability.Communication.NetStack
1403     * @crossplatform
1404     * @since 10
1405     */
1406    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
1407
1408    /**
1409     * Obtains the peer address of a TLSSocket connection.
1410     * @returns { Promise<NetAddress> } The promise returned by the function.
1411     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1412     * @throws { BusinessError } 2300002 - System internal error.
1413     * @syscap SystemCapability.Communication.NetStack
1414     * @since 9
1415     */
1416    /**
1417     * Obtains the peer address of a TLSSocket connection.
1418     * @returns { Promise<NetAddress> } The promise returned by the function.
1419     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1420     * @throws { BusinessError } 2300002 - System internal error.
1421     * @syscap SystemCapability.Communication.NetStack
1422     * @crossplatform
1423     * @since 10
1424     */
1425    getRemoteAddress(): Promise<NetAddress>;
1426
1427    /**
1428     * Obtains the status of the TLSSocket connection.
1429     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState.
1430     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1431     * @throws { BusinessError } 2300002 - System internal error.
1432     * @syscap SystemCapability.Communication.NetStack
1433     * @since 9
1434     */
1435    /**
1436     * Obtains the status of the TLSSocket connection.
1437     * @param { AsyncCallback<SocketStateBase> } callback - the callback of getState.
1438     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1439     * @throws { BusinessError } 2300002 - System internal error.
1440     * @syscap SystemCapability.Communication.NetStack
1441     * @crossplatform
1442     * @since 10
1443     */
1444    getState(callback: AsyncCallback<SocketStateBase>): void;
1445
1446    /**
1447     * Obtains the status of the TLSSocket connection.
1448     * @returns { Promise<SocketStateBase> } The promise returned by the function.
1449     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1450     * @throws { BusinessError } 2300002 - System internal error.
1451     * @syscap SystemCapability.Communication.NetStack
1452     * @since 9
1453     */
1454    /**
1455     * Obtains the status of the TLSSocket connection.
1456     * @returns { Promise<SocketStateBase> } The promise returned by the function.
1457     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1458     * @throws { BusinessError } 2300002 - System internal error.
1459     * @syscap SystemCapability.Communication.NetStack
1460     * @crossplatform
1461     * @since 10
1462     */
1463    getState(): Promise<SocketStateBase>;
1464
1465    /**
1466     * Sets other attributes of the TLSSocket connection.
1467     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
1468     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
1469     * @throws { BusinessError } 401 - Parameter error.
1470     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1471     * @throws { BusinessError } 2300002 - System internal error.
1472     * @syscap SystemCapability.Communication.NetStack
1473     * @since 9
1474     */
1475    /**
1476     * Sets other attributes of the TLSSocket connection.
1477     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
1478     * @param { AsyncCallback<void> } callback - the callback of setExtraOptions.
1479     * @throws { BusinessError } 401 - Parameter error.
1480     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1481     * @throws { BusinessError } 2300002 - System internal error.
1482     * @syscap SystemCapability.Communication.NetStack
1483     * @crossplatform
1484     * @since 10
1485     */
1486    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
1487
1488    /**
1489     * Sets other attributes of the TLSSocket connection.
1490     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
1491     * @returns { Promise<void> } The promise returned by the function.
1492     * @throws { BusinessError } 401 - Parameter error.
1493     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1494     * @throws { BusinessError } 2300002 - System internal error.
1495     * @syscap SystemCapability.Communication.NetStack
1496     * @since 9
1497     */
1498    /**
1499     * Sets other attributes of the TLSSocket connection.
1500     * @param { TCPExtraOptions } options - Optional parameters {@link TCPExtraOptions}.
1501     * @returns { Promise<void> } The promise returned by the function.
1502     * @throws { BusinessError } 401 - Parameter error.
1503     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1504     * @throws { BusinessError } 2300002 - System internal error.
1505     * @syscap SystemCapability.Communication.NetStack
1506     * @crossplatform
1507     * @since 10
1508     */
1509    setExtraOptions(options: TCPExtraOptions): Promise<void>;
1510
1511    /**
1512     * Listens for message receiving events of the TLSSocket connection.
1513     * @param { 'message' } type - Indicates Event name.
1514     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
1515     * @throws { BusinessError } 401 - Parameter error.
1516     * @syscap SystemCapability.Communication.NetStack
1517     * @since 9
1518     */
1519    /**
1520     * Listens for message receiving events of the TLSSocket connection.
1521     * @param { 'message' } type Indicates Event name.
1522     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
1523     * @throws { BusinessError } 401 - Parameter error.
1524     * @syscap SystemCapability.Communication.NetStack
1525     * @crossplatform
1526     * @since 10
1527     */
1528    on(type: 'message', callback: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
1529
1530    /**
1531     * Cancels listening for message receiving events of the TLSSocket connection.
1532     * @param { 'message' } type - Indicates Event name.
1533     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
1534     * @throws { BusinessError } 401 - Parameter error.
1535     * @syscap SystemCapability.Communication.NetStack
1536     * @since 9
1537     */
1538    /**
1539     * Cancels listening for message receiving events of the TLSSocket connection.
1540     * @param { 'message' } type Indicates Event name.
1541     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - the callback used to return the result.
1542     * @throws { BusinessError } 401 - Parameter error.
1543     * @syscap SystemCapability.Communication.NetStack
1544     * @crossplatform
1545     * @since 10
1546     */
1547    off(type: 'message', callback?: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
1548
1549    /**
1550     * Listens for connection or close events of the TLSSocket connection.
1551     * @param { 'connect' | 'close' } type - Indicates Event name.
1552     * @param {Callback<void> } callback - the callback used to return the result.
1553     * @throws { BusinessError } 401 - Parameter error.
1554     * @syscap SystemCapability.Communication.NetStack
1555     * @since 9
1556     */
1557    /**
1558     * Listens for connection or close events of the TLSSocket connection.
1559     * @param { 'connect' | 'close' } type - Indicates Event name.
1560     * @param {Callback<void> } callback - the callback used to return the result.
1561     * @throws { BusinessError } 401 - Parameter error.
1562     * @syscap SystemCapability.Communication.NetStack
1563     * @crossplatform
1564     * @since 10
1565     */
1566    on(type: 'connect' | 'close', callback: Callback<void>): void;
1567
1568    /**
1569     * Cancels listening for connection or close events of the TLSSocket connection.
1570     * @param { 'connect' | 'close' } type - Indicates Event name.
1571     * @param {Callback<void> } callback - the callback used to return the result.
1572     * @throws { BusinessError } 401 - Parameter error.
1573     * @syscap SystemCapability.Communication.NetStack
1574     * @since 9
1575     */
1576    /**
1577     * Cancels listening for connection or close events of the TLSSocket connection.
1578     * @param { 'connect' | 'close' } type - Indicates Event name.
1579     * @param {Callback<void> } callback - the callback used to return the result.
1580     * @throws { BusinessError } 401 - Parameter error.
1581     * @syscap SystemCapability.Communication.NetStack
1582     * @crossplatform
1583     * @since 10
1584     */
1585    off(type: 'connect' | 'close', callback?: Callback<void>): void;
1586
1587    /**
1588     * Listens for error events of the TLSSocket connection.
1589     * @param { 'error' } type - Indicates Event name.
1590     * @param { ErrorCallback } callback - the callback used to return the result.
1591     * @throws { BusinessError } 401 - Parameter error.
1592     * @syscap SystemCapability.Communication.NetStack
1593     * @since 9
1594     */
1595    /**
1596     * Listens for error events of the TLSSocket connection.
1597     * @param { 'error' } type - Indicates Event name.
1598     * @param { ErrorCallback } callback - the callback used to return the result.
1599     * @throws { BusinessError } 401 - Parameter error.
1600     * @syscap SystemCapability.Communication.NetStack
1601     * @crossplatform
1602     * @since 10
1603     */
1604    on(type: 'error', callback: ErrorCallback): void;
1605
1606    /**
1607     * Cancels listening for error events of the TLSSocket connection.
1608     * @param { 'error' } type - Indicates Event name.
1609     * @param { ErrorCallback } callback - the callback used to return the result.
1610     * @throws { BusinessError } 401 - Parameter error.
1611     * @syscap SystemCapability.Communication.NetStack
1612     * @since 9
1613     */
1614    /**
1615     * Cancels listening for error events of the TLSSocket connection.
1616     * @param { 'error' } type - Indicates Event name.
1617     * @param { ErrorCallback } callback - the callback used to return the result.
1618     * @throws { BusinessError } 401 - Parameter error.
1619     * @syscap SystemCapability.Communication.NetStack
1620     * @crossplatform
1621     * @since 10
1622     */
1623    off(type: 'error', callback?: ErrorCallback): void;
1624
1625    /**
1626     * Returns an object representing a local certificate.
1627     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getCertificate.
1628     * @throws { BusinessError } 2303501 - SSL is null.
1629     * @throws { BusinessError } 2303504 - Error looking up x509
1630     * @throws { BusinessError } 2300002 - System internal error.
1631     * @syscap SystemCapability.Communication.NetStack
1632     * @since 9
1633     */
1634    /**
1635     * Returns an object representing a local certificate.
1636     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getCertificate.
1637     * @throws { BusinessError } 2303501 - SSL is null.
1638     * @throws { BusinessError } 2303504 - Error looking up x509
1639     * @throws { BusinessError } 2300002 - System internal error.
1640     * @syscap SystemCapability.Communication.NetStack
1641     * @crossplatform
1642     * @since 10
1643     */
1644    getCertificate(callback: AsyncCallback<X509CertRawData>): void;
1645
1646    /**
1647     * Returns an object representing a local certificate.
1648     * @returns { Promise<X509CertRawData> } The promise returned by the function.
1649     * @throws { BusinessError } 2303501 - SSL is null.
1650     * @throws { BusinessError } 2303504 - Error looking up x509
1651     * @throws { BusinessError } 2300002 - System internal error.
1652     * @syscap SystemCapability.Communication.NetStack
1653     * @since 9
1654     */
1655    /**
1656     * Returns an object representing a local certificate.
1657     * @returns { Promise<X509CertRawData> } The promise returned by the function.
1658     * @throws { BusinessError } 2303501 - SSL is null.
1659     * @throws { BusinessError } 2303504 - Error looking up x509
1660     * @throws { BusinessError } 2300002 - System internal error.
1661     * @syscap SystemCapability.Communication.NetStack
1662     * @crossplatform
1663     * @since 10
1664     */
1665    getCertificate(): Promise<X509CertRawData>;
1666
1667    /**
1668     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
1669     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
1670     * It only contains the peer's certificate.
1671     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getRemoteCertificate.
1672     * @throws { BusinessError } 2303501 - SSL is null.
1673     * @throws { BusinessError } 2300002 - System internal error.
1674     * @syscap SystemCapability.Communication.NetStack
1675     * @since 9
1676     */
1677    /**
1678     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
1679     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
1680     * It only contains the peer's certificate.
1681     * @param { AsyncCallback<X509CertRawData> } callback - the callback of getRemoteCertificate.
1682     * @throws { BusinessError } 2303501 - SSL is null.
1683     * @throws { BusinessError } 2300002 - System internal error.
1684     * @syscap SystemCapability.Communication.NetStack
1685     * @crossplatform
1686     * @since 10
1687     */
1688    getRemoteCertificate(callback: AsyncCallback<X509CertRawData>): void;
1689
1690    /**
1691     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
1692     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
1693     * It only contains the peer's certificate.
1694     * @returns { Promise<X509CertRawData> } The promise returned by the function.
1695     * @throws { BusinessError } 2303501 - SSL is null.
1696     * @throws { BusinessError } 2300002 - System internal error.
1697     * @syscap SystemCapability.Communication.NetStack
1698     * @since 9
1699     */
1700    /**
1701     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
1702     * <p>an empty object will be returned. If the socket is destroyed, null is returned.</p>
1703     * It only contains the peer's certificate.
1704     * @returns { Promise<X509CertRawData> } The promise returned by the function.
1705     * @throws { BusinessError } 2303501 - SSL is null.
1706     * @throws { BusinessError } 2300002 - System internal error.
1707     * @syscap SystemCapability.Communication.NetStack
1708     * @crossplatform
1709     * @since 10
1710     */
1711    getRemoteCertificate(): Promise<X509CertRawData>;
1712
1713    /**
1714     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
1715     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
1716     * Server sockets or disconnected client sockets will return a value of null.
1717     * @param { AsyncCallback<string> } callback - the callback of getProtocol.
1718     * @throws { BusinessError } 2303501 - SSL is null.
1719     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1720     * @throws { BusinessError } 2300002 - System internal error.
1721     * @syscap SystemCapability.Communication.NetStack
1722     * @since 9
1723     */
1724    /**
1725     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
1726     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
1727     * Server sockets or disconnected client sockets will return a value of null.
1728     * @param { AsyncCallback<string> } callback - the callback of getProtocol.
1729     * @throws { BusinessError } 2303501 - SSL is null.
1730     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1731     * @throws { BusinessError } 2300002 - System internal error.
1732     * @syscap SystemCapability.Communication.NetStack
1733     * @crossplatform
1734     * @since 10
1735     */
1736    getProtocol(callback: AsyncCallback<string>): void;
1737
1738    /**
1739     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
1740     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
1741     * Server sockets or disconnected client sockets will return a value of null.
1742     * @returns { Promise<string> } The promise returned by the function.
1743     * @throws { BusinessError } 2303501 - SSL is null.
1744     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1745     * @throws { BusinessError } 2300002 - System internal error.
1746     * @syscap SystemCapability.Communication.NetStack
1747     * @since 9
1748     */
1749    /**
1750     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
1751     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
1752     * Server sockets or disconnected client sockets will return a value of null.
1753     * @returns { Promise<string> } The promise returned by the function.
1754     * @throws { BusinessError } 2303501 - SSL is null.
1755     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1756     * @throws { BusinessError } 2300002 - System internal error.
1757     * @syscap SystemCapability.Communication.NetStack
1758     * @crossplatform
1759     * @since 10
1760     */
1761    getProtocol(): Promise<string>;
1762
1763    /**
1764     * Returns a list containing the negotiated cipher suite information.
1765     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
1766     * @param { AsyncCallback<Array<string>> } callback - the callback of getCipherSuite.
1767     * @throws { BusinessError } 2303501 - SSL is null.
1768     * @throws { BusinessError } 2303502 - Error in tls reading.
1769     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1770     * @throws { BusinessError } 2300002 - System internal error.
1771     * @syscap SystemCapability.Communication.NetStack
1772     * @since 9
1773     */
1774    /**
1775     * Returns a list containing the negotiated cipher suite information.
1776     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
1777     * @param { AsyncCallback<Array<string>> } callback - the callback of getCipherSuite.
1778     * @throws { BusinessError } 2303501 - SSL is null.
1779     * @throws { BusinessError } 2303502 - Error in tls reading.
1780     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1781     * @throws { BusinessError } 2300002 - System internal error.
1782     * @syscap SystemCapability.Communication.NetStack
1783     * @crossplatform
1784     * @since 10
1785     */
1786    getCipherSuite(callback: AsyncCallback<Array<string>>): void;
1787
1788    /**
1789     * Returns a list containing the negotiated cipher suite information.
1790     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
1791     * @returns { Promise<Array<string>> } The promise returned by the function.
1792     * @throws { BusinessError } 2303501 - SSL is null.
1793     * @throws { BusinessError } 2303502 - Error in tls reading.
1794     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1795     * @throws { BusinessError } 2300002 - System internal error.
1796     * @syscap SystemCapability.Communication.NetStack
1797     * @since 9
1798     */
1799    /**
1800     * Returns a list containing the negotiated cipher suite information.
1801     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
1802     * @returns { Promise<Array<string>> } The promise returned by the function.
1803     * @throws { BusinessError } 2303501 - SSL is null.
1804     * @throws { BusinessError } 2303502 - Error in tls reading.
1805     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1806     * @throws { BusinessError } 2300002 - System internal error.
1807     * @syscap SystemCapability.Communication.NetStack
1808     * @crossplatform
1809     * @since 10
1810     */
1811    getCipherSuite(): Promise<Array<string>>;
1812
1813    /**
1814     * <p>The list of signature algorithms shared between the server and the client,
1815     * in descending order of priority.</p>
1816     * @param { AsyncCallback<Array<string>> } callback - the callback of getSignatureAlgorithms.@see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html
1817     * @throws { BusinessError } 2303501 - SSL is null.
1818     * @throws { BusinessError } 2300002 - System internal error.
1819     * @syscap SystemCapability.Communication.NetStack
1820     * @since 9
1821     */
1822    /**
1823     * <p>The list of signature algorithms shared between the server and the client,
1824     * in descending order of priority.</p>
1825     * @param { AsyncCallback<Array<string>> } callback - the callback of getSignatureAlgorithms.@see https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html
1826     * @throws { BusinessError } 2303501 - SSL is null.
1827     * @throws { BusinessError } 2300002 - System internal error.
1828     * @syscap SystemCapability.Communication.NetStack
1829     * @crossplatform
1830     * @since 10
1831     */
1832    getSignatureAlgorithms(callback: AsyncCallback<Array<string>>): void;
1833
1834    /**
1835     * <p>The list of signature algorithms shared between the server and the client,
1836     * in descending order of priority.</p>
1837     * @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
1838     * @throws { BusinessError } 2303501 - SSL is null.
1839     * @throws { BusinessError } 2300002 - System internal error.
1840     * @syscap SystemCapability.Communication.NetStack
1841     * @since 9
1842     */
1843    /**
1844     * <p>The list of signature algorithms shared between the server and the client,
1845     * in descending order of priority.</p>
1846     * @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
1847     * @throws { BusinessError } 2303501 - SSL is null.
1848     * @throws { BusinessError } 2300002 - System internal error.
1849     * @syscap SystemCapability.Communication.NetStack
1850     * @crossplatform
1851     * @since 10
1852     */
1853    getSignatureAlgorithms(): Promise<Array<string>>;
1854
1855    /**
1856     * Sets up a connection to the specified IP address and port number.
1857     * Only TCP is supported.
1858     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
1859     * @param { AsyncCallback<void> } callback - the callback of connect.
1860     * @throws { BusinessError } 401 - Parameter error.
1861     * @throws { BusinessError } 2303104 - Interrupted system call.
1862     * @throws { BusinessError } 2303109 - Bad file number.
1863     * @throws { BusinessError } 2303111 - Resource temporarily unavailable try again.
1864     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1865     * @throws { BusinessError } 2303191 - Protocol wrong type for socket.
1866     * @throws { BusinessError } 2303198 - Address already in use.
1867     * @throws { BusinessError } 2303199 - Cannot assign requested address.
1868     * @throws { BusinessError } 2303210 - Connection timed out.
1869     * @throws { BusinessError } 2303501 - SSL is null.
1870     * @throws { BusinessError } 2303502 - Error in tls reading.
1871     * @throws { BusinessError } 2303503 - Error in tls writing
1872     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1873     * @throws { BusinessError } 2303506 - Error clearing tls connection.
1874     * @throws { BusinessError } 2300002 - System internal error.
1875     * @syscap SystemCapability.Communication.NetStack
1876     * @since 9
1877     */
1878    /**
1879     * Sets up a connection to the specified IP address and port number.
1880     * Only TCP is supported.
1881     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
1882     * @param { AsyncCallback<void> } callback - the callback of connect.
1883     * @throws { BusinessError } 401 - Parameter error.
1884     * @throws { BusinessError } 2303104 - Interrupted system call.
1885     * @throws { BusinessError } 2303109 - Bad file number.
1886     * @throws { BusinessError } 2303111 - Resource temporarily unavailable try again.
1887     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1888     * @throws { BusinessError } 2303191 - Protocol wrong type for socket.
1889     * @throws { BusinessError } 2303198 - Address already in use.
1890     * @throws { BusinessError } 2303199 - Cannot assign requested address.
1891     * @throws { BusinessError } 2303210 - Connection timed out.
1892     * @throws { BusinessError } 2303501 - SSL is null.
1893     * @throws { BusinessError } 2303502 - Error in tls reading.
1894     * @throws { BusinessError } 2303503 - Error in tls writing
1895     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1896     * @throws { BusinessError } 2303506 - Error clearing tls connection.
1897     * @throws { BusinessError } 2300002 - System internal error.
1898     * @syscap SystemCapability.Communication.NetStack
1899     * @crossplatform
1900     * @since 10
1901     */
1902    connect(options: TLSConnectOptions, callback: AsyncCallback<void>): void;
1903
1904    /**
1905     * Sets up a connection to the specified IP address and port number.
1906     * Only TCP is supported.
1907     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
1908     * @returns { Promise<void> } The promise returned by the function.
1909     * @throws { BusinessError } 401 - Parameter error.
1910     * @throws { BusinessError } 2303104 - Interrupted system call.
1911     * @throws { BusinessError } 2303109 - Bad file number.
1912     * @throws { BusinessError } 2303111 - Resource temporarily unavailable try again.
1913     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1914     * @throws { BusinessError } 2303191 - Protocol wrong type for socket.
1915     * @throws { BusinessError } 2303198 - Address already in use.
1916     * @throws { BusinessError } 2303199 - Cannot assign requested address.
1917     * @throws { BusinessError } 2303210 - Connection timed out.
1918     * @throws { BusinessError } 2303501 - SSL is null.
1919     * @throws { BusinessError } 2303502 - Error in tls reading.
1920     * @throws { BusinessError } 2303503 - Error in tls writing
1921     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1922     * @throws { BusinessError } 2303506 - Error clearing tls connection.
1923     * @throws { BusinessError } 2300002 - System internal error.
1924     * @syscap SystemCapability.Communication.NetStack
1925     * @since 9
1926     */
1927    /**
1928     * Sets up a connection to the specified IP address and port number.
1929     * Only TCP is supported.
1930     * @param { TLSConnectOptions } options - Optional parameters {@link TLSConnectOptions}.
1931     * @returns { Promise<void> } The promise returned by the function.
1932     * @throws { BusinessError } 401 - Parameter error.
1933     * @throws { BusinessError } 2303104 - Interrupted system call.
1934     * @throws { BusinessError } 2303109 - Bad file number.
1935     * @throws { BusinessError } 2303111 - Resource temporarily unavailable try again.
1936     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
1937     * @throws { BusinessError } 2303191 - Protocol wrong type for socket.
1938     * @throws { BusinessError } 2303198 - Address already in use.
1939     * @throws { BusinessError } 2303199 - Cannot assign requested address.
1940     * @throws { BusinessError } 2303210 - Connection timed out.
1941     * @throws { BusinessError } 2303501 - SSL is null.
1942     * @throws { BusinessError } 2303502 - Error in tls reading.
1943     * @throws { BusinessError } 2303503 - Error in tls writing
1944     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1945     * @throws { BusinessError } 2303506 - Error clearing tls connection.
1946     * @throws { BusinessError } 2300002 - System internal error.
1947     * @syscap SystemCapability.Communication.NetStack
1948     * @crossplatform
1949     * @since 10
1950     */
1951    connect(options: TLSConnectOptions): Promise<void>;
1952
1953    /**
1954     * Sends data over a TLSSocket connection.
1955     * @param { string } data - Optional parameters {@link string}.
1956     * @param { AsyncCallback<void> } callback - the callback of send.
1957     * @throws { BusinessError } 401 - Parameter error.
1958     * @throws { BusinessError } 2303501 - SSL is null.
1959     * @throws { BusinessError } 2303503 - Error in tls writing.
1960     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1961     * @throws { BusinessError } 2303506 - Error clearing tls connection.
1962     * @throws { BusinessError } 2300002 - System internal error.
1963     * @syscap SystemCapability.Communication.NetStack
1964     * @since 9
1965     */
1966    /**
1967     * Sends data over a TLSSocket connection.
1968     * @param { string } data - Optional parameters {@link string}.
1969     * @param { AsyncCallback<void> } callback - the callback of send.
1970     * @throws { BusinessError } 401 - Parameter error.
1971     * @throws { BusinessError } 2303501 - SSL is null.
1972     * @throws { BusinessError } 2303503 - Error in tls writing.
1973     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1974     * @throws { BusinessError } 2303506 - Error clearing tls connection.
1975     * @throws { BusinessError } 2300002 - System internal error.
1976     * @syscap SystemCapability.Communication.NetStack
1977     * @crossplatform
1978     * @since 10
1979     */
1980    send(data: string, callback: AsyncCallback<void>): void;
1981
1982    /**
1983     * Sends data over a TLSSocket connection.
1984     * @param { string } data - Optional parameters {@link string}.
1985     * @returns { Promise<void> } The promise returned by the function.
1986     * @throws { BusinessError } 401 - Parameter error.
1987     * @throws { BusinessError } 2303501 - SSL is null.
1988     * @throws { BusinessError } 2303503 - Error in tls writing.
1989     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
1990     * @throws { BusinessError } 2303506 - Error clearing tls connection.
1991     * @throws { BusinessError } 2300002 - System internal error.
1992     * @syscap SystemCapability.Communication.NetStack
1993     * @since 9
1994     */
1995    /**
1996     * Sends data over a TLSSocket connection.
1997     * @param { string } data - Optional parameters {@link string}.
1998     * @returns { Promise<void> } The promise returned by the function.
1999     * @throws { BusinessError } 401 - Parameter error.
2000     * @throws { BusinessError } 2303501 - SSL is null.
2001     * @throws { BusinessError } 2303503 - Error in tls writing.
2002     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2003     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2004     * @throws { BusinessError } 2300002 - System internal error.
2005     * @syscap SystemCapability.Communication.NetStack
2006     * @crossplatform
2007     * @since 10
2008     */
2009    send(data: string): Promise<void>;
2010
2011    /**
2012     * Closes a TLSSocket connection
2013     * @param { AsyncCallback<void> } callback - the callback of close.
2014     * @throws { BusinessError } 401 - Parameter error.
2015     * @throws { BusinessError } 2303501 - SSL is null.
2016     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2017     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2018     * @throws { BusinessError } 2300002 - System internal error.
2019     * @syscap SystemCapability.Communication.NetStack
2020     * @since 9
2021     */
2022    /**
2023     * Closes a TLSSocket connection
2024     * @param { AsyncCallback<void> } callback - the callback of close.
2025     * @throws { BusinessError } 401 - Parameter error.
2026     * @throws { BusinessError } 2303501 - SSL is null.
2027     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2028     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2029     * @throws { BusinessError } 2300002 - System internal error.
2030     * @syscap SystemCapability.Communication.NetStack
2031     * @crossplatform
2032     * @since 10
2033     */
2034    close(callback: AsyncCallback<void>): void;
2035
2036    /**
2037     * Closes a TLSSocket connection
2038     * @returns { Promise<void> } The promise returned by the function.
2039     * @throws { BusinessError } 401 - Parameter error.
2040     * @throws { BusinessError } 2303501 - SSL is null.
2041     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2042     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2043     * @throws { BusinessError } 2300002 - System internal error.
2044     * @syscap SystemCapability.Communication.NetStack
2045     * @since 9
2046     */
2047    /**
2048     * Closes a TLSSocket connection
2049     * @returns { Promise<void> } The promise returned by the function.
2050     * @throws { BusinessError } 401 - Parameter error.
2051     * @throws { BusinessError } 2303501 - SSL is null.
2052     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2053     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2054     * @throws { BusinessError } 2300002 - System internal error.
2055     * @syscap SystemCapability.Communication.NetStack
2056     * @crossplatform
2057     * @since 10
2058     */
2059    close(): Promise<void>;
2060  }
2061
2062  /**
2063   * Defines TLS security options. The CA certificate is mandatory, and other parameters are optional.
2064   * @interface TLSSecureOptions
2065   * @syscap SystemCapability.Communication.NetStack
2066   * @since 9
2067   */
2068  /**
2069   * Defines TLS security options. The CA certificate is mandatory, and other parameters are optional.
2070   * @interface TLSSecureOptions
2071   * @syscap SystemCapability.Communication.NetStack
2072   * @crossplatform
2073   * @since 10
2074   */
2075  export interface TLSSecureOptions {
2076    /**
2077     * Certificate used to verify the identity of the server
2078     * @type {string | Array<string>}
2079     * @syscap SystemCapability.Communication.NetStack
2080     * @since 9
2081     */
2082    /**
2083     * Certificate used to verify the identity of the server
2084     * @type {string | Array<string>}
2085     * @syscap SystemCapability.Communication.NetStack
2086     * @crossplatform
2087     * @since 10
2088     */
2089    ca: string | Array<string>;
2090
2091    /**
2092     * Certificate proving the identity of the client
2093     * @type {?string}
2094     * @syscap SystemCapability.Communication.NetStack
2095     * @since 9
2096     */
2097    /**
2098     * Certificate proving the identity of the client
2099     * @type {?string}
2100     * @syscap SystemCapability.Communication.NetStack
2101     * @crossplatform
2102     * @since 10
2103     */
2104    cert?: string;
2105
2106    /**
2107     * Private key of client certificate
2108     * @type {?string}
2109     * @syscap SystemCapability.Communication.NetStack
2110     * @since 9
2111     */
2112    /**
2113     * Private key of client certificate
2114     * @type {?string}
2115     * @syscap SystemCapability.Communication.NetStack
2116     * @crossplatform
2117     * @since 10
2118     */
2119    key?: string;
2120
2121    /**
2122     * Password of the private key
2123     * @type {?string}
2124     * @syscap SystemCapability.Communication.NetStack
2125     * @since 9
2126     */
2127    /**
2128     * Password of the private key
2129     * @type {?string}
2130     * @syscap SystemCapability.Communication.NetStack
2131     * @crossplatform
2132     * @since 10
2133     */
2134    password?: string;
2135
2136    /**
2137     * TLS protocol version
2138     * @type {?Protocol | Array<Protocol>}
2139     * @syscap SystemCapability.Communication.NetStack
2140     * @since 9
2141     */
2142    /**
2143     * TLS protocol version
2144     * @type {?Protocol | Array<Protocol>}
2145     * @syscap SystemCapability.Communication.NetStack
2146     * @crossplatform
2147     * @since 10
2148     */
2149    protocols?: Protocol | Array<Protocol>;
2150
2151    /**
2152     * default is false, use local cipher.
2153     * @type {?boolean}
2154     * @syscap SystemCapability.Communication.NetStack
2155     * @since 9
2156     */
2157    /**
2158     * default is false, use local cipher.
2159     * @type {?boolean}
2160     * @syscap SystemCapability.Communication.NetStack
2161     * @crossplatform
2162     * @since 10
2163     */
2164    useRemoteCipherPrefer?: boolean;
2165
2166    /**
2167     * <P>Supported signature algorithms. This string can contain summary algorithms(SHA256,MD5,etc),Public key algorithm(RSA-PSS,ECDSA,etc),
2168     * Combination of the two(For example 'RSA+SHA384') or TLS v1.3 Scheme name(For example  rsa_pss_pss_sha512)</P>
2169     * @type {?string}
2170     * @syscap SystemCapability.Communication.NetStack
2171     * @since 9
2172     */
2173    /**
2174     * <P>Supported signature algorithms. This string can contain summary algorithms(SHA256,MD5,etc),Public key algorithm(RSA-PSS,ECDSA,etc),
2175     * Combination of the two(For example 'RSA+SHA384') or TLS v1.3 Scheme name(For example  rsa_pss_pss_sha512)</P>
2176     * @type {?string}
2177     * @syscap SystemCapability.Communication.NetStack
2178     * @crossplatform
2179     * @since 10
2180     */
2181    signatureAlgorithms?: string;
2182
2183    /**
2184     * Crypto suite specification
2185     * @type {?string}
2186     * @syscap SystemCapability.Communication.NetStack
2187     * @since 9
2188     */
2189    /**
2190     * Crypto suite specification
2191     * @type {?string}
2192     * @syscap SystemCapability.Communication.NetStack
2193     * @crossplatform
2194     * @since 10
2195     */
2196    cipherSuite?: string;
2197  }
2198
2199  /**
2200   * Defines TLS connection options.
2201   * @interface TLSConnectOptions
2202   * @syscap SystemCapability.Communication.NetStack
2203   * @since 9
2204   */
2205  /**
2206   * Defines TLS connection options.
2207   * @interface TLSConnectOptions
2208   * @syscap SystemCapability.Communication.NetStack
2209   * @crossplatform
2210   * @since 10
2211   */
2212  export interface TLSConnectOptions {
2213    /**
2214     * Gateway address.
2215     * @type {NetAddress}
2216     * @syscap SystemCapability.Communication.NetStack
2217     * @since 9
2218     */
2219    /**
2220     * Gateway address.
2221     * @type {NetAddress}
2222     * @syscap SystemCapability.Communication.NetStack
2223     * @crossplatform
2224     * @since 10
2225     */
2226    address: NetAddress;
2227
2228    /**
2229     * Protocol http2TLS security related operations.
2230     * @type {TLSSecureOptions}
2231     * @syscap SystemCapability.Communication.NetStack
2232     * @since 9
2233     */
2234    /**
2235     * Protocol http2TLS security related operations.
2236     * @type {TLSSecureOptions}
2237     * @syscap SystemCapability.Communication.NetStack
2238     * @crossplatform
2239     * @since 10
2240     */
2241    secureOptions: TLSSecureOptions;
2242
2243    /**
2244     * Application layer protocol negotiation extension, such as "spdy/1", "http/1.1", "h2"
2245     * @type {?Array<string>}
2246     * @syscap SystemCapability.Communication.NetStack
2247     * @since 9
2248     */
2249    /**
2250     * Application layer protocol negotiation extension, such as "spdy/1", "http/1.1", "h2"
2251     * @type {?Array<string>}
2252     * @syscap SystemCapability.Communication.NetStack
2253     * @crossplatform
2254     * @since 10
2255     */
2256    ALPNProtocols?: Array<string>;
2257  }
2258
2259  /**
2260   * Enumerates TLS protocol versions.
2261   * @enum {string}
2262   * @syscap SystemCapability.Communication.NetStack
2263   * @since 9
2264   */
2265  /**
2266   * Enumerates TLS protocol versions.
2267   * @enum {string}
2268   * @syscap SystemCapability.Communication.NetStack
2269   * @crossplatform
2270   * @since 10
2271   */
2272  export enum Protocol {
2273    /**
2274     * Use TLSv1.2 protocol for communication.
2275     * @syscap SystemCapability.Communication.NetStack
2276     * @since 9
2277     */
2278    /**
2279     * Use TLSv1.2 protocol for communication.
2280     * @syscap SystemCapability.Communication.NetStack
2281     * @crossplatform
2282     * @since 10
2283     */
2284    TLSv12 = "TLSv1.2",
2285
2286    /**
2287     * Use TLSv1.3 protocol for communication.
2288     * @syscap SystemCapability.Communication.NetStack
2289     * @since 9
2290     */
2291    /**
2292     * Use TLSv1.3 protocol for communication.
2293     * @syscap SystemCapability.Communication.NetStack
2294     * @crossplatform
2295     * @since 10
2296     */
2297    TLSv13 = "TLSv1.3"
2298  }
2299
2300  /**
2301   * Defines the connection of the TCPSocket client and server.
2302   * @interface TCPSocketConnection
2303   * @syscap SystemCapability.Communication.NetStack
2304   * @since 10
2305   */
2306  export interface TCPSocketConnection {
2307    /**
2308     * The id of a client connects to the TCPSocketServer.
2309     * @type {number}
2310     * @syscap SystemCapability.Communication.NetStack
2311     * @since 10
2312     */
2313    clientId: number;
2314
2315    /**
2316     * Sends data over a TCPSocketServer connection to client.
2317     * @permission ohos.permission.INTERNET
2318     * @param { TCPSendOptions } options - Parameters for sending data {@link TCPSendOptions}.
2319     * @param { AsyncCallback<void> } callback - The callback of send.
2320     * @throws { BusinessError } 201 - Permission denied.
2321     * @throws { BusinessError } 401 - Parameter error.
2322     * @throws { BusinessError } 2300002 - System internal error.
2323     * @syscap SystemCapability.Communication.NetStack
2324     * @since 10
2325     */
2326    send(options: TCPSendOptions, callback: AsyncCallback<void>): void;
2327
2328    /**
2329     * Sends data over a TCPSocketServer connection to client.
2330     * @permission ohos.permission.INTERNET
2331     * @param { TCPSendOptions } options - Parameters for sending data {@link TCPSendOptions}.
2332     * @returns { Promise<void> } The promise returned by the function.
2333     * @throws { BusinessError } 201 - Permission denied.
2334     * @throws { BusinessError } 401 - Parameter error.
2335     * @throws { BusinessError } 2300002 - System internal error.
2336     * @syscap SystemCapability.Communication.NetStack
2337     * @since 10
2338     */
2339    send(options: TCPSendOptions): Promise<void>;
2340
2341    /**
2342     * Closes a TCPSocket client connection.
2343     * @permission ohos.permission.INTERNET
2344     * @param { AsyncCallback<void> } callback - The callback of close.
2345     * @throws { BusinessError } 201 - Permission denied.
2346     * @throws { BusinessError } 401 - Parameter error.
2347     * @throws { BusinessError } 2300002 - System internal error.
2348     * @syscap SystemCapability.Communication.NetStack
2349     * @since 10
2350     */
2351    close(callback: AsyncCallback<void>): void;
2352
2353    /**
2354     * Closes a TCPSocket client connection.
2355     * @permission ohos.permission.INTERNET
2356     * @returns { Promise<void> } The promise returned by the function.
2357     * @throws { BusinessError } 201 - Permission denied.
2358     * @throws { BusinessError } 2300002 - System internal error.
2359     * @syscap SystemCapability.Communication.NetStack
2360     * @since 10
2361     */
2362    close(): Promise<void>;
2363
2364    /**
2365     * Obtains the peer address of a TCPSocketServer connection.
2366     * @permission ohos.permission.INTERNET
2367     * @param { AsyncCallback<NetAddress> } callback - The callback of getRemoteAddress.
2368     * @throws { BusinessError } 201 - Permission denied.
2369     * @throws { BusinessError } 401 - Parameter error.
2370     * @throws { BusinessError } 2300002 - System internal error.
2371     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2372     * @syscap SystemCapability.Communication.NetStack
2373     * @since 10
2374     */
2375    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
2376
2377    /**
2378     * Obtains the peer address of a TCPSocketServer connection.
2379     * @permission ohos.permission.INTERNET
2380     * @returns { Promise<NetAddress> } The promise returned by the function.
2381     * @throws { BusinessError } 201 - Permission denied.
2382     * @throws { BusinessError } 2300002 - System internal error.
2383     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2384     * @syscap SystemCapability.Communication.NetStack
2385     * @since 10
2386     */
2387    getRemoteAddress(): Promise<NetAddress>;
2388
2389    /**
2390     * Listens for message receiving events of the TCPSocketConnection.
2391     * @param { 'message' } type - Indicates Event name.
2392     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of on.
2393     * @throws { BusinessError } 401 - Parameter error.
2394     * @syscap SystemCapability.Communication.NetStack
2395     * @since 10
2396     */
2397    on(type: 'message', callback: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
2398
2399    /**
2400     * Cancels listening for message receiving events of the TCPSocketConnection.
2401     * @param { 'message' } type - Indicates Event name.
2402     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of off.
2403     * @throws { BusinessError } 401 - Parameter error.
2404     * @syscap SystemCapability.Communication.NetStack
2405     * @since 10
2406     */
2407    off(type: 'message', callback?: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
2408
2409    /**
2410     * Listens for close events of the TCPSocketConnection.
2411     * @param { 'close' } type - Indicates Event name.
2412     * @param { Callback<void> } callback - The callback of on.
2413     * @throws { BusinessError } 401 - Parameter error.
2414     * @syscap SystemCapability.Communication.NetStack
2415     * @since 10
2416     */
2417    on(type: 'close', callback: Callback<void>): void;
2418
2419    /**
2420     * Cancels listening for close events of the TCPSocketConnection.
2421     * @param { 'close' } type - Indicates Event name.
2422     * @param { Callback<void> } callback - The callback of off.
2423     * @throws { BusinessError } 401 - Parameter error.
2424     * @syscap SystemCapability.Communication.NetStack
2425     * @since 10
2426     */
2427    off(type: 'close', callback?: Callback<void>): void;
2428
2429    /**
2430     * Listens for error events of the TCPSocketConnection.
2431     * @param { 'error' } type - Indicates Event name.
2432     * @param { ErrorCallback } callback - The callback of on.
2433     * @throws { BusinessError } 401 - Parameter error.
2434     * @syscap SystemCapability.Communication.NetStack
2435     * @since 10
2436     */
2437    on(type: 'error', callback: ErrorCallback): void;
2438
2439    /**
2440     * Cancels listening for error events of the TCPSocketConnection.
2441     * @param { 'error' } type - Indicates Event name.
2442     * @param { ErrorCallback } callback - The callback of off.
2443     * @throws { BusinessError } 401 - Parameter error.
2444     * @syscap SystemCapability.Communication.NetStack
2445     * @since 10
2446     */
2447    off(type: 'error', callback?: ErrorCallback): void;
2448  }
2449
2450  /**
2451   * Defines a TCPSocket server connection.
2452   * @interface TCPSocketServer
2453   * @syscap SystemCapability.Communication.NetStack
2454   * @since 10
2455   */
2456  export interface TCPSocketServer {
2457    /**
2458     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
2459     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
2460     * for accept processing and uses poll multiplex to process client connections.</p>
2461     * @permission ohos.permission.INTERNET
2462     * @param { NetAddress } address - Network address information {@link NetAddress}.
2463     * @param { AsyncCallback<void> } callback - The callback of listen.
2464     * @throws { BusinessError } 401 - Parameter error.
2465     * @throws { BusinessError } 201 - Permission denied.
2466     * @throws { BusinessError } 2300002 - System internal error.
2467     * @throws { BusinessError } 2303109 - Bad file number.
2468     * @throws { BusinessError } 2303111 - Resource temporarily unavailable try again.
2469     * @throws { BusinessError } 2303198 - Address already in use.
2470     * @throws { BusinessError } 2303199 - Cannot assign requested address.
2471     * @syscap SystemCapability.Communication.NetStack
2472     * @since 10
2473     */
2474    listen(address: NetAddress, callback: AsyncCallback<void>): void;
2475
2476    /**
2477     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
2478     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
2479     * for accept processing and uses poll multiplex to process client connections.</p>
2480     * @permission ohos.permission.INTERNET
2481     * @param { NetAddress } address - Network address information {@link NetAddress}.
2482     * @returns { Promise<void> } The promise returned by the function.
2483     * @throws { BusinessError } 401 - Parameter error.
2484     * @throws { BusinessError } 201 - Permission denied.
2485     * @throws { BusinessError } 2300002 - System internal error.
2486     * @throws { BusinessError } 2303109 - Bad file number.
2487     * @throws { BusinessError } 2303111 - Resource temporarily unavailable try again.
2488     * @throws { BusinessError } 2303198 - Address already in use.
2489     * @throws { BusinessError } 2303199 - Cannot assign requested address.
2490     * @syscap SystemCapability.Communication.NetStack
2491     * @since 10
2492     */
2493    listen(address: NetAddress): Promise<void>;
2494
2495    /**
2496     * Obtains the status of the TCPSocketServer connection.
2497     * @permission ohos.permission.INTERNET
2498     * @param { AsyncCallback<SocketStateBase> } callback - The callback of getState.
2499     * @throws { BusinessError } 201 - Permission denied.
2500     * @throws { BusinessError } 401 - Parameter error.
2501     * @throws { BusinessError } 2300002 - System internal error.
2502     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2503     * @syscap SystemCapability.Communication.NetStack
2504     * @since 10
2505     */
2506    getState(callback: AsyncCallback<SocketStateBase>): void;
2507
2508    /**
2509     * Obtains the status of the TCPSocketServer connection.
2510     * @permission ohos.permission.INTERNET
2511     * @returns { Promise<SocketStateBase> } The promise returned by the function.
2512     * @throws { BusinessError } 201 - Permission denied.
2513     * @throws { BusinessError } 2300002 - System internal error.
2514     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2515     * @syscap SystemCapability.Communication.NetStack
2516     * @since 10
2517     */
2518    getState(): Promise<SocketStateBase>;
2519
2520    /**
2521     * Sets other attributes of the TCPSocketServer connection.
2522     * @permission ohos.permission.INTERNET
2523     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
2524     * @param { AsyncCallback<void> } callback - The callback of setExtraOptions.
2525     * @throws { BusinessError } 201 - Permission denied.
2526     * @throws { BusinessError } 401 - Parameter error.
2527     * @throws { BusinessError } 2300002 - System internal error.
2528     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2529     * @syscap SystemCapability.Communication.NetStack
2530     * @since 10
2531     */
2532    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
2533
2534    /**
2535     * Sets other attributes of the TCPSocketServer connection.
2536     * @permission ohos.permission.INTERNET
2537     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
2538     * @returns { Promise<void> } The promise returned by the function.
2539     * @throws { BusinessError } 201 - Permission denied.
2540     * @throws { BusinessError } 401 - Parameter error.
2541     * @throws { BusinessError } 2300002 - System internal error.
2542     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2543     * @syscap SystemCapability.Communication.NetStack
2544     * @since 10
2545     */
2546    setExtraOptions(options: TCPExtraOptions): Promise<void>;
2547
2548    /**
2549     * Listens for connect events of the TCPSocketServer connection.
2550     * @param { 'connect' } type - Indicates Event name.
2551     * @param { Callback<TCPSocketConnection> } callback - The callback of on.
2552     * @throws { BusinessError } 401 - Parameter error.
2553     * @syscap SystemCapability.Communication.NetStack
2554     * @since 10
2555     */
2556    on(type: 'connect', callback: Callback<TCPSocketConnection>): void;
2557
2558    /**
2559     * Cancels listening for connect events of the TCPSocketServer connection.
2560     * @param { 'connect' } type - Indicates Event name.
2561     * @param { Callback<TCPSocketConnection> } callback - The callback of off.
2562     * @throws { BusinessError } 401 - Parameter error.
2563     * @syscap SystemCapability.Communication.NetStack
2564     * @since 10
2565     */
2566    off(type: 'connect', callback?: Callback<TCPSocketConnection>): void;
2567
2568    /**
2569     * Listens for error events of the TCPSocketServer connection.
2570     * @param { 'error' } type - Indicates Event name.
2571     * @param { ErrorCallback } callback - The callback of on.
2572     * @throws { BusinessError } 401 - Parameter error.
2573     * @syscap SystemCapability.Communication.NetStack
2574     * @since 10
2575     */
2576    on(type: 'error', callback: ErrorCallback): void;
2577
2578    /**
2579     * Cancels listening for error events of the TCPSocketServer connection.
2580     * @param { 'error' } type - Indicates Event name.
2581     * @param { ErrorCallback } callback - The callback of off.
2582     * @throws { BusinessError } 401 - Parameter error.
2583     * @syscap SystemCapability.Communication.NetStack
2584     * @since 10
2585     */
2586    off(type: 'error', callback?: ErrorCallback): void;
2587  }
2588
2589  /**
2590   * Defines the connection of the TLSSocket client and server.
2591   * @interface TLSSocketConnection
2592   * @syscap SystemCapability.Communication.NetStack
2593   * @since 10
2594   */
2595  export interface TLSSocketConnection {
2596    /**
2597     * The id of a client connects to the TLSSocketServer.
2598     * @type {number}
2599     * @syscap SystemCapability.Communication.NetStack
2600     * @since 10
2601     */
2602    clientId: number;
2603
2604    /**
2605     * Sends data over a TLSSocketServer connection to client.
2606     * @param { string } data - Parameters for sending data.
2607     * @param { AsyncCallback<void> } callback - The callback of send.
2608     * @throws { BusinessError } 401 - Parameter error.
2609     * @throws { BusinessError } 2303501 - SSL is null.
2610     * @throws { BusinessError } 2303503 - Error in tls writing.
2611     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2612     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2613     * @throws { BusinessError } 2300002 - System internal error.
2614     * @syscap SystemCapability.Communication.NetStack
2615     * @since 10
2616     */
2617    send(data: string, callback: AsyncCallback<void>): void;
2618
2619    /**
2620     * Sends data over a TLSSocketServer connection to client.
2621     * @param { string } data - Parameters for sending data.
2622     * @returns { Promise<void> } The promise returned by the function.
2623     * @throws { BusinessError } 401 - Parameter error.
2624     * @throws { BusinessError } 2303501 - SSL is null.
2625     * @throws { BusinessError } 2303503 - Error in tls writing.
2626     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2627     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2628     * @throws { BusinessError } 2300002 - System internal error.
2629     * @syscap SystemCapability.Communication.NetStack
2630     * @since 10
2631     */
2632    send(data: string): Promise<void>;
2633
2634    /**
2635     * Closes a TLSSocket client connection.
2636     * @param { AsyncCallback<void> } callback - The callback of close.
2637     * @throws { BusinessError } 401 - Parameter error.
2638     * @throws { BusinessError } 2303501 - SSL is null.
2639     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2640     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2641     * @throws { BusinessError } 2300002 - System internal error.
2642     * @syscap SystemCapability.Communication.NetStack
2643     * @since 10
2644     */
2645    close(callback: AsyncCallback<void>): void;
2646
2647    /**
2648     * Closes a TLSSocket client connection.
2649     * @returns { Promise<void> } The promise returned by the function.
2650     * @throws { BusinessError } 2303501 - SSL is null.
2651     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2652     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2653     * @throws { BusinessError } 2300002 - System internal error.
2654     * @syscap SystemCapability.Communication.NetStack
2655     * @since 10
2656     */
2657    close(): Promise<void>;
2658
2659    /**
2660     * Obtains the peer address of a TLSSocketServer connection.
2661     * @param { AsyncCallback<NetAddress> } callback - The callback of getRemoteAddress.
2662     * @throws { BusinessError } 401 - Parameter error.
2663     * @throws { BusinessError } 2300002 - System internal error.
2664     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2665     * @syscap SystemCapability.Communication.NetStack
2666     * @since 10
2667     */
2668    getRemoteAddress(callback: AsyncCallback<NetAddress>): void;
2669
2670    /**
2671     * Obtains the peer address of a TLSSocketServer connection.
2672     * @returns { Promise<NetAddress> } The promise returned by the function.
2673     * @throws { BusinessError } 2300002 - System internal error.
2674     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2675     * @syscap SystemCapability.Communication.NetStack
2676     * @since 10
2677     */
2678    getRemoteAddress(): Promise<NetAddress>;
2679
2680    /**
2681     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
2682     * an empty object will be returned. If the socket is destroyed, null is returned.</p>
2683     * It only contains the peer's certificate.
2684     * @param { AsyncCallback<X509CertRawData> } callback - The callback of getRemoteCertificate.
2685     * @throws { BusinessError } 401 - Parameter error.
2686     * @throws { BusinessError } 2303501 - SSL is null.
2687     * @throws { BusinessError } 2300002 - System internal error.
2688     * @syscap SystemCapability.Communication.NetStack
2689     * @since 10
2690     */
2691    getRemoteCertificate(callback: AsyncCallback<X509CertRawData>): void;
2692
2693    /**
2694     * <p>Returns an object representing the peer certificate. If the peer does not provide a certificate,
2695     * an empty object will be returned. If the socket is destroyed, null is returned.</p>
2696     * It only contains the peer's certificate.
2697     * @returns { Promise<X509CertRawData> } The promise returned by the function.
2698     * @throws { BusinessError } 2303501 - SSL is null.
2699     * @throws { BusinessError } 2300002 - System internal error.
2700     * @syscap SystemCapability.Communication.NetStack
2701     * @since 10
2702     */
2703    getRemoteCertificate(): Promise<X509CertRawData>;
2704
2705    /**
2706     * Returns a list containing the negotiated cipher suite information.
2707     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
2708     * @param { AsyncCallback<Array<string>> } callback - The callback of getCipherSuite.
2709     * @throws { BusinessError } 401 - Parameter error.
2710     * @throws { BusinessError } 2303501 - SSL is null.
2711     * @throws { BusinessError } 2303502 - Error in tls reading.
2712     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2713     * @throws { BusinessError } 2300002 - System internal error.
2714     * @syscap SystemCapability.Communication.NetStack
2715     * @since 10
2716     */
2717    getCipherSuite(callback: AsyncCallback<Array<string>>): void;
2718
2719    /**
2720     * Returns a list containing the negotiated cipher suite information.
2721     * For example:{"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"}
2722     * @returns { Promise<Array<string>> } The promise returned by the function.
2723     * @throws { BusinessError } 2303501 - SSL is null.
2724     * @throws { BusinessError } 2303502 - Error in tls reading.
2725     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2726     * @throws { BusinessError } 2300002 - System internal error.
2727     * @syscap SystemCapability.Communication.NetStack
2728     * @since 10
2729     */
2730    getCipherSuite(): Promise<Array<string>>;
2731
2732    /**
2733     * <p>The list of signature algorithms shared between the server and the client,
2734     * in descending order of priority.</p>
2735     * @param { AsyncCallback<Array<string>> } callback - The callback of getSignatureAlgorithms.
2736     * @throws { BusinessError } 401 - Parameter error.
2737     * @throws { BusinessError } 2303501 - SSL is null.
2738     * @throws { BusinessError } 2300002 - System internal error.
2739     * @syscap SystemCapability.Communication.NetStack
2740     * @since 10
2741     */
2742    getSignatureAlgorithms(callback: AsyncCallback<Array<string>>): void;
2743
2744    /**
2745     * <p>The list of signature algorithms shared between the server and the client,
2746     * in descending order of priority.</p>
2747     * @returns { Promise<Array<string>> } The promise returned by the function.
2748     * @throws { BusinessError } 2303501 - SSL is null.
2749     * @throws { BusinessError } 2300002 - System internal error.
2750     * @syscap SystemCapability.Communication.NetStack
2751     * @since 10
2752     */
2753    getSignatureAlgorithms(): Promise<Array<string>>;
2754
2755    /**
2756     * Listens for message receiving events of the TLSSocketConnection.
2757     * @param { 'message' } type - Indicates Event name.
2758     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of on.
2759     * @throws { BusinessError } 401 - Parameter error.
2760     * @syscap SystemCapability.Communication.NetStack
2761     * @since 10
2762     */
2763    on(type: 'message', callback: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
2764
2765    /**
2766     * Cancels listening for message receiving events of the TLSSocketConnection.
2767     * @param { 'message' } type - Indicates Event name.
2768     * @param { Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }> } callback - The callback of off.
2769     * @throws { BusinessError } 401 - Parameter error.
2770     * @syscap SystemCapability.Communication.NetStack
2771     * @since 10
2772     */
2773    off(type: 'message', callback?: Callback<{ message: ArrayBuffer, remoteInfo: SocketRemoteInfo }>): void;
2774
2775    /**
2776     * Listens for close events of the TLSSocketConnection.
2777     * @param { 'close' } type - Indicates Event name.
2778     * @param { Callback<void> } callback - The callback of on.
2779     * @throws { BusinessError } 401 - Parameter error.
2780     * @syscap SystemCapability.Communication.NetStack
2781     * @since 10
2782     */
2783    on(type: 'close', callback: Callback<void>): void;
2784
2785    /**
2786     * Cancels listening for close events of the TLSSocketConnection.
2787     * @param { 'close' } type - Indicates Event name.
2788     * @param { Callback<void> } callback - The callback of off.
2789     * @throws { BusinessError } 401 - Parameter error.
2790     * @syscap SystemCapability.Communication.NetStack
2791     * @since 10
2792     */
2793    off(type: 'close', callback?: Callback<void>): void;
2794
2795    /**
2796     * Listens for error events of the TLSSocketConnection.
2797     * @param { 'error' } type - Indicates Event name.
2798     * @param { ErrorCallback } callback - The callback of on.
2799     * @throws { BusinessError } 401 - Parameter error.
2800     * @syscap SystemCapability.Communication.NetStack
2801     * @since 10
2802     */
2803    on(type: 'error', callback: ErrorCallback): void;
2804
2805    /**
2806     * Cancels listening for error events of the TLSSocketConnection.
2807     * @param { 'error' } type - Indicates Event name.
2808     * @param { ErrorCallback } callback - The callback of off.
2809     * @throws { BusinessError } 401 - Parameter error.
2810     * @syscap SystemCapability.Communication.NetStack
2811     * @since 10
2812     */
2813    off(type: 'error', callback?: ErrorCallback): void;
2814  }
2815
2816  /**
2817   * Defines a TLSSocketServer server connection.
2818   * @interface TLSSocketServer
2819   * @syscap SystemCapability.Communication.NetStack
2820   * @since 10
2821   */
2822  export interface TLSSocketServer {
2823    /**
2824     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
2825     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
2826     * for accept processing and uses poll multiplex to process client connections.</p>
2827     * @permission ohos.permission.INTERNET
2828     * @param { TLSConnectOptions } options - TLS connection options {@link TLSConnectOptions}.
2829     * @param { AsyncCallback<void> } callback - The callback of listen.
2830     * @throws { BusinessError } 401 - Parameter error.
2831     * @throws { BusinessError } 201 - Permission denied.
2832     * @throws { BusinessError } 2300002 - System internal error.
2833     * @throws { BusinessError } 2303109 - Bad file number.
2834     * @throws { BusinessError } 2303111 - Resource temporarily unavailable try again.
2835     * @throws { BusinessError } 2303198 - Address already in use.
2836     * @throws { BusinessError } 2303199 - Cannot assign requested address.
2837     * @throws { BusinessError } 2303501 - SSL is null.
2838     * @throws { BusinessError } 2303502 - Error in tls reading.
2839     * @throws { BusinessError } 2303503 - Error in tls writing
2840     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2841     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2842     * @syscap SystemCapability.Communication.NetStack
2843     * @since 10
2844     */
2845    listen(options: TLSConnectOptions, callback: AsyncCallback<void>): void;
2846
2847    /**
2848     * Binds the IP address and port number, the port number can be specified or randomly allocated by the system.
2849     * <p>Listens for a TCPSocket connection to be made to this socket and accepts it. This interface uses multiple threads
2850     * for accept processing and uses poll multiplex to process client connections.</p>
2851     * @permission ohos.permission.INTERNET
2852     * @param { TLSConnectOptions } options - TLS connection options {@link TLSConnectOptions}.
2853     * @returns { Promise<void> } The promise returned by the function.
2854     * @throws { BusinessError } 401 - Parameter error.
2855     * @throws { BusinessError } 201 - Permission denied.
2856     * @throws { BusinessError } 2300002 - System internal error.
2857     * @throws { BusinessError } 2303109 - Bad file number.
2858     * @throws { BusinessError } 2303111 - Resource temporarily unavailable try again.
2859     * @throws { BusinessError } 2303198 - Address already in use.
2860     * @throws { BusinessError } 2303199 - Cannot assign requested address.
2861     * @throws { BusinessError } 2303501 - SSL is null.
2862     * @throws { BusinessError } 2303502 - Error in tls reading.
2863     * @throws { BusinessError } 2303503 - Error in tls writing
2864     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2865     * @throws { BusinessError } 2303506 - Error clearing tls connection.
2866     * @syscap SystemCapability.Communication.NetStack
2867     * @since 10
2868     */
2869    listen(options: TLSConnectOptions): Promise<void>;
2870
2871    /**
2872     * Obtains the status of the TLSSocketServer connection.
2873     * @param { AsyncCallback<SocketStateBase> } callback - The callback of getState.
2874     * @throws { BusinessError } 401 - Parameter error.
2875     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2876     * @throws { BusinessError } 2300002 - System internal error.
2877     * @syscap SystemCapability.Communication.NetStack
2878     * @since 10
2879     */
2880    getState(callback: AsyncCallback<SocketStateBase>): void;
2881
2882    /**
2883     * Obtains the status of the TLSSocketServer connection.
2884     * @returns { Promise<SocketStateBase> } The promise returned by the function.
2885     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2886     * @throws { BusinessError } 2300002 - System internal error.
2887     * @syscap SystemCapability.Communication.NetStack
2888     * @since 10
2889     */
2890    getState(): Promise<SocketStateBase>;
2891
2892    /**
2893     * Sets other attributes of the TLSSocketServer connection.
2894     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
2895     * @param { AsyncCallback<void> } callback - The callback of setExtraOptions.
2896     * @throws { BusinessError } 401 - Parameter error.
2897     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2898     * @throws { BusinessError } 2300002 - System internal error.
2899     * @syscap SystemCapability.Communication.NetStack
2900     * @since 10
2901     */
2902    setExtraOptions(options: TCPExtraOptions, callback: AsyncCallback<void>): void;
2903
2904    /**
2905     * Sets other attributes of the TLSSocketServer connection.
2906     * @param { TCPExtraOptions } options - Parameters of the attributes {@link TCPExtraOptions}.
2907     * @returns { Promise<void> } The promise returned by the function.
2908     * @throws { BusinessError } 401 - Parameter error.
2909     * @throws { BusinessError } 2303188 - Socket operation on non-socket.
2910     * @throws { BusinessError } 2300002 - System internal error.
2911     * @syscap SystemCapability.Communication.NetStack
2912     * @since 10
2913     */
2914    setExtraOptions(options: TCPExtraOptions): Promise<void>;
2915
2916    /**
2917     * Returns an object representing a local certificate.
2918     * @param { AsyncCallback<X509CertRawData> } callback - The callback of getCertificate.
2919     * @throws { BusinessError } 401 - Parameter error.
2920     * @throws { BusinessError } 2303501 - SSL is null.
2921     * @throws { BusinessError } 2303504 - Error looking up x509
2922     * @throws { BusinessError } 2300002 - System internal error.
2923     * @syscap SystemCapability.Communication.NetStack
2924     * @since 10
2925     */
2926    getCertificate(callback: AsyncCallback<X509CertRawData>): void;
2927
2928    /**
2929     * Returns an object representing a local certificate.
2930     * @returns { Promise<X509CertRawData> } The promise returned by the function.
2931     * @throws { BusinessError } 2303501 - SSL is null.
2932     * @throws { BusinessError } 2303504 - Error looking up x509
2933     * @throws { BusinessError } 2300002 - System internal error.
2934     * @syscap SystemCapability.Communication.NetStack
2935     * @since 10
2936     */
2937    getCertificate(): Promise<X509CertRawData>;
2938
2939    /**
2940     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
2941     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
2942     * Server sockets or disconnected client sockets will return a value of null.
2943     * @param { AsyncCallback<string> } callback - The callback of getProtocol.
2944     * @throws { BusinessError } 401 - Parameter error.
2945     * @throws { BusinessError } 2303501 - SSL is null.
2946     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2947     * @throws { BusinessError } 2300002 - System internal error.
2948     * @syscap SystemCapability.Communication.NetStack
2949     * @since 10
2950     */
2951    getProtocol(callback: AsyncCallback<string>): void;
2952
2953    /**
2954     * Returns a string containing the negotiated SSL/TLS protocol version of the current connection.
2955     * For connected sockets that have not completed the handshake process, the value 'unknown' will be returned.
2956     * Server sockets or disconnected client sockets will return a value of null.
2957     * @returns { Promise<string> } The promise returned by the function.
2958     * @throws { BusinessError } 2303501 - SSL is null.
2959     * @throws { BusinessError } 2303505 - Error occurred in the tls system call.
2960     * @throws { BusinessError } 2300002 - System internal error.
2961     * @syscap SystemCapability.Communication.NetStack
2962     * @since 10
2963     */
2964    getProtocol(): Promise<string>;
2965
2966    /**
2967     * Listens for connect events of the TLSSocketServer connection.
2968     * @param { 'connect' } type - Indicates Event name.
2969     * @param { Callback<TLSSocketConnection> } callback - The callback of on.
2970     * @throws { BusinessError } 401 - Parameter error.
2971     * @syscap SystemCapability.Communication.NetStack
2972     * @since 10
2973     */
2974    on(type: 'connect', callback: Callback<TLSSocketConnection>): void;
2975
2976    /**
2977     * Cancels listening for connect events of the TLSSocketServer connection.
2978     * @param { 'connect' } type - Indicates Event name.
2979     * @param { Callback<TLSSocketConnection> } callback - The callback of off.
2980     * @throws { BusinessError } 401 - Parameter error.
2981     * @syscap SystemCapability.Communication.NetStack
2982     * @since 10
2983     */
2984    off(type: 'connect', callback?: Callback<TLSSocketConnection>): void;
2985
2986    /**
2987     * Listens for error events of the TLSSocketServer connection.
2988     * @param { 'error' } type - Indicates Event name.
2989     * @param { ErrorCallback } callback - The callback of on.
2990     * @throws { BusinessError } 401 - Parameter error.
2991     * @syscap SystemCapability.Communication.NetStack
2992     * @since 10
2993     */
2994    on(type: 'error', callback: ErrorCallback): void;
2995
2996    /**
2997     * Cancels listening for error events of the TLSSocketServer connection.
2998     * @param { 'error' } type - Indicates Event name.
2999     * @param { ErrorCallback } callback - The callback of off.
3000     * @throws { BusinessError } 401 - Parameter error.
3001     * @syscap SystemCapability.Communication.NetStack
3002     * @since 10
3003     */
3004    off(type: 'error', callback?: ErrorCallback): void;
3005  }
3006}
3007
3008export default socket;
3009