This commit is contained in:
Marc Mültin 2020-07-23 17:38:37 +01:00
commit 0711b49b69
3 changed files with 8 additions and 2 deletions

View File

@ -139,6 +139,7 @@ public class TCPClient extends StatefulTransportLayerClient {
getInStream().close(); getInStream().close();
getOutStream().close(); getOutStream().close();
getTcpSocketToServer().close(); getTcpSocketToServer().close();
uniqueTCPClientInstance = null;
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch (IOException e) { } catch (IOException e) {
getLogger().error("Error occurred while trying to close TCP socket to server", e); getLogger().error("Error occurred while trying to close TCP socket to server", e);

View File

@ -220,6 +220,7 @@ public class TLSClient extends StatefulTransportLayerClient {
getInStream().close(); getInStream().close();
getOutStream().close(); getOutStream().close();
getTlsSocketToServer().close(); getTlsSocketToServer().close();
uniqueTLSClientInstance = null;
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} catch (IOException e) { } catch (IOException e) {
getLogger().error("Error occurred while trying to close TCP socket to server", e); getLogger().error("Error occurred while trying to close TCP socket to server", e);

View File

@ -51,7 +51,7 @@ public class UDPClient {
* access the instance variable -> thread safe. * access the instance variable -> thread safe.
*/ */
private Logger logger = LogManager.getLogger(this.getClass().getSimpleName()); private Logger logger = LogManager.getLogger(this.getClass().getSimpleName());
private static final UDPClient uniqueUDPClientInstance = new UDPClient(); private static UDPClient uniqueUDPClientInstance = new UDPClient();
private int multicastSocketPort; private int multicastSocketPort;
private Inet6Address multicastAddress; private Inet6Address multicastAddress;
private MulticastSocket socketToUDPServer; private MulticastSocket socketToUDPServer;
@ -105,7 +105,10 @@ public class UDPClient {
} }
public static UDPClient getInstance() { public static synchronized UDPClient getInstance() {
if (uniqueUDPClientInstance == null) {
uniqueUDPClientInstance = new UDPClient();
}
return uniqueUDPClientInstance; return uniqueUDPClientInstance;
} }
@ -144,6 +147,7 @@ public class UDPClient {
public void stop() { public void stop() {
getSocketToUDPServer().close(); getSocketToUDPServer().close();
getLogger().debug("UDP client stopped"); getLogger().debug("UDP client stopped");
uniqueUDPClientInstance = null;
} }