From 830e47a67026205b75f69e061d81783aa606a237 Mon Sep 17 00:00:00 2001 From: 562935844@qq.com Date: 星期五, 23 九月 2022 16:23:26 +0800 Subject: [PATCH] tcp发送之前判断是否连接 --- HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/client/UdpClient.java | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/client/UdpClient.java b/HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/client/UdpClient.java index 07d368d..8a78384 100644 --- a/HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/client/UdpClient.java +++ b/HDLSDK/hdl-socket/src/main/java/com/hdl/sdk/socket/client/UdpClient.java @@ -87,7 +87,7 @@ * @return */ public static UdpSocketBoot init(int port, UdpSocketOptions options) { - return init(null, port, options); + return init("0.0.0.0", port, options); } @@ -100,9 +100,11 @@ } if (TextUtils.isEmpty(ipAddress)) { mSocket = SocketPool.getInstance().getUdpSocket(new InetSocketAddress(port)); + }else { + mSocket = SocketPool.getInstance().getUdpSocket(new InetSocketAddress(ipAddress,port)); } mSocket.setBroadcast(true); - mSocket.setReuseAddress(true); +// mSocket.setReuseAddress(true); } catch (Exception e) { LogUtils.e("鍒濆鍖朣ocket 澶辫触锛�" + e.getMessage()); -- Gitblit v1.8.0