I use the following code to send a DatagramPacket to a given address:
InetAddress address = InetAddress.getByName(anIPAddress); DatagramSocket socket = new DatagramSocket(); DatagramPacket packet = new DatagramPacket(packetBytes, packetBytes.length, address, port); socket.send(packet); socket.close();
It works fine, but how does this code throw no Exception when there is no internet connection available?
I will disable both Wi-Fi and mobile data, and this code still executes without any errors.
Is there any way to make sure the package is really shipped?
(I donโt care if it reached the goal or not, I just wanted to make sure it was sent)
java android udp
justanoob
source share