From 4e5147e82bf3708042369e531e1d7ed88a4c6d47 Mon Sep 17 00:00:00 2001 From: fanqibing Date: Sat, 14 Jun 2025 18:46:00 +0800 Subject: [PATCH] add close interface for server Signed-off-by: fanqibing --- api/@ohos.net.socket.d.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/api/@ohos.net.socket.d.ts b/api/@ohos.net.socket.d.ts index df3a30f810..5b5530074b 100644 --- a/api/@ohos.net.socket.d.ts +++ b/api/@ohos.net.socket.d.ts @@ -2037,6 +2037,15 @@ declare namespace socket { */ getLocalAddress(): Promise; + /** + * Close the server. Close the server listening port. + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 2300002 - System internal error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + */ + close(): Promise; + /** * Listens for connect events of the LocalSocketServer connection. * @param { 'connect' } type - Indicates Event name. @@ -4167,6 +4176,17 @@ declare namespace socket { */ listen(address: NetAddress): Promise; + /** + * Close the server. Close the server listening port. + * @permission ohos.permission.INTERNET + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2300002 - System internal error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + */ + close(): Promise; + /** * Obtains the status of the TCPSocketServer connection. * @permission ohos.permission.INTERNET @@ -4651,6 +4671,17 @@ declare namespace socket { */ listen(options: TLSConnectOptions): Promise; + /** + * Close the server. Close the server listening port. + * @permission ohos.permission.INTERNET + * @returns { Promise } The promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 2300002 - System internal error. + * @syscap SystemCapability.Communication.NetStack + * @since 20 + */ + close(): Promise; + /** * Obtains the status of the TLSSocketServer connection. * @param { AsyncCallback } callback - The callback of getState. -- Gitee