Receive on UDP socket and send reply

You must set the destination address in the DatagramPacket before sending it.

The constructor you're using (without the address) is just for receiving, not for sending.

In UDP protocol, destination is set in the packet because there is not a connection (like TCP) So in your code you are telling the socket, which has no concecpt of destination to send a packet without destination, so it'll throw and exception.

InetSocketAddress address = InetSocketAddress("www.google.com", 8080);
DatagramPacket replyPacket = new DatagramPacket(buffer, buffer.length, address); 
socket.send(replyPacket);