0
votes

I have been trying to send an UDP packet from an EC2 instance to itself. I received an exception:

java.net.UnknownHostException: xx.xxx.xxx.xxx: Name or service not known

It was generated from the line:

DatagramPacket packet = new DatagramPacket(buf, buf.length, InetAddress.getByName(destination), RPCServer.PORTNUM);

I am sure this exception is from InetAddress.getByName(destination), in which destination is a string of the raw IP address of my EC2 instance. Could anyone tell me how I can get around this exception?

1

1 Answers

0
votes

I have solved the problem by using Inetaddress.getByAddress(DESTINATION), here DESTINATION is a byte array converted from the IP string destination.