I am trying to implement basic Datagram Sockets in Android. I am starting with one of the samples available on the web:
I have enables the INTERNET permissions in AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
The program dies when it hits the s.send(p) command.
What am I missing? It must be something obvious.
Thanks,
Dan
Code:
String messageStr="Hello Android!";
int server_port = 54372;
try {
DatagramSocket s = new DatagramSocket();
InetAddress local = null;
local = InetAddress.getByName("192.168.100.127");
int msg_length=messageStr.length();
byte[] message = messageStr.getBytes();
DatagramPacket p = new DatagramPacket(message, msg_length, local, server_port);
s.send(p);
} catch (SocketException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
<uses-permission android:name="android.permission.INTERNET"/>
The program dies when it hits the s.send(p) command.
What am I missing? It must be something obvious.
Thanks,
Dan