From 89c38fa6f118d56cb163c245905de8f1c0a75a7c Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期二, 19 三月 2024 18:03:50 +0800 Subject: [PATCH] 2024年03月19日18:03:44 --- app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpService.java | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpService.java b/app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpService.java index 95441dc..f0a065b 100644 --- a/app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpService.java +++ b/app/src/main/java/com/hdl/photovoltaic/internet/HttpServer/MyNanoHttpService.java @@ -4,8 +4,16 @@ import android.content.Intent; import android.os.Binder; import android.os.IBinder; +import android.text.TextUtils; import androidx.annotation.Nullable; + +import com.hdl.photovoltaic.other.HdlLogLogic; + +import org.w3c.dom.Text; + +import java.io.IOException; +import java.util.Objects; /** * 鏈湴鏈嶅姟鍣� @@ -21,7 +29,26 @@ try { myNanoHttpServer.start(); } catch (Exception e) { - e.printStackTrace(); +// if (myNanoHttpServer!=null&&myNanoHttpServer.gserverSocket.isBound() && !serverSocket.isClosed()) { +// // Port is available +// } else { +// // Port is not available +// } +// e.printStackTrace(); +// if (!TextUtils.isEmpty(e.getMessage()) && Objects.requireNonNull(e.getMessage()).contains("Address already in use")) { +// myNanoHttpServer = null; +// for (int i = MyNanoHttpServer.HTTP_PORT + 1; i < 65535; i++) { +// try { +// MyNanoHttpServer.HTTP_PORT = i; +// myNanoHttpServer = MyNanoHttpServer.getInstance(null); +// myNanoHttpServer.start(); +// } catch (Exception ex) { +// String s = ex.getMessage(); +// } +// } +// +// } + HdlLogLogic.print("鍒濆鍖朒ttp鏈嶅姟鍣ㄥけ璐�--->" + e.getMessage(), true); startService(new Intent(this, MyNanoHttpService.class)); } } -- Gitblit v1.8.0