mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
ensure closing of datagram socket in arcane Util
This commit is contained in:
parent
63dbfb8a9b
commit
338e9833cc
1 changed files with 7 additions and 3 deletions
|
|
@ -37,9 +37,13 @@ public final class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcast(byte[] data, int port) throws IOException {
|
public static void broadcast(byte[] data, int port) throws IOException {
|
||||||
DatagramSocket socket = new DatagramSocket();
|
DatagramSocket socket = null;
|
||||||
broadcast(socket, data, port, NetworkInterface.getNetworkInterfaces());
|
try {
|
||||||
socket.close();
|
socket = new DatagramSocket();
|
||||||
|
broadcast(socket, data, port, NetworkInterface.getNetworkInterfaces());
|
||||||
|
} finally {
|
||||||
|
socket.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void broadcast(DatagramSocket socket, byte[] data, int port, Enumeration<NetworkInterface> ifaces)
|
private static void broadcast(DatagramSocket socket, byte[] data, int port, Enumeration<NetworkInterface> ifaces)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue