Hello ,
I'm new at android\java so be patient
I want to create a small application that send a udp string to my server when I press the button.
everything is working - but it doesn't seem to send
this is what I have
btnAction.setOnClickListener(new View.OnClickListener() {
@ override
public void onClick(View v) {
try {
String messageStr = "test!";
int server_port = 1111;
DatagramSocket s = new DatagramSocket();
InetAddress local = InetAddress.getByName("My.Public.Server.IP");
int msg_length = messageStr.length();
byte[] message = messageStr.getBytes();
DatagramPacket p = new DatagramPacket(message, msg_length, local,server_port);
s.send(p);
}
catch (Exception e) {
}
}
}
whant could be the reason for it?
Thanks ,
I'm new at android\java so be patient
I want to create a small application that send a udp string to my server when I press the button.
everything is working - but it doesn't seem to send
this is what I have
btnAction.setOnClickListener(new View.OnClickListener() {
@ override
public void onClick(View v) {
try {
String messageStr = "test!";
int server_port = 1111;
DatagramSocket s = new DatagramSocket();
InetAddress local = InetAddress.getByName("My.Public.Server.IP");
int msg_length = messageStr.length();
byte[] message = messageStr.getBytes();
DatagramPacket p = new DatagramPacket(message, msg_length, local,server_port);
s.send(p);
}
catch (Exception e) {
}
}
}
whant could be the reason for it?
Thanks ,
Last edited by a moderator: