2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 21:55:10 +00:00

Fail if server is not ready when we try to broadcast

This commit is contained in:
Albert Vaca Cintora
2021-03-16 20:47:41 +01:00
parent 1c31d3cb49
commit bb5b6f4fea

View File

@@ -367,7 +367,10 @@ public class LanLinkProvider extends BaseLinkProvider implements LanLink.LinkDis
}
NetworkPacket identity = NetworkPacket.createIdentityPacket(context);
int port = (tcpServer == null || !tcpServer.isBound()) ? MIN_PORT : tcpServer.getLocalPort();
if (tcpServer == null || !tcpServer.isBound()) {
throw new RuntimeException("Wont't broadcast UDP packet if TCP socket is not ready");
}
int port = tcpServer.getLocalPort();
identity.set("tcpPort", port);
DatagramSocket socket = null;
byte[] bytes = null;