Note that there are some explanatory texts on larger screens.

plurals
  1. POUDP server doesn't accept calls from outside
    text
    copied!<p>I've implement simple udp server on my Android device.(sdk 1.5) it works fine when I am running a local client on the phone sends through it trigger to my server.</p> <p>but when I try to get udp call from an outside server to my phone, it doesnt work. already make sure the outside server isn't blocked by firewall and it's sending the udp trigger to the right port, which my phone is listening to.</p> <p>I used natstat on the phone and checked that the phone is really listening to the its local ip and the port I've setted it to.</p> <p>here is my code of the server:(on the device)</p> <pre><code> // server will listen to one client try { Thread udpServerThread = new Thread() { @Override public void run() { try { // Retrieve the ServerName InetAddress serverAddr = InetAddress .getByName("localhost"); Log.d("UDP", "S: Connecting..."); // Create new UDP-Socket socket = new DatagramSocket(SERVERPORT,serverAddr); byte[] buf = new byte[17]; // * Prepare a UDP-Packet that can contain the data we // * want to receive DatagramPacket packet = new DatagramPacket(buf, buf.length); Log.d("UDP", "S: Receiving..."); // wait to Receive the UDP-Packet socket.receive(packet); Log.d("UDP", "S: Received: '" + new String(packet.getData()) + "'"); acceptedMsg=new String(packet.getData()); notifyService(acceptedMsg); Log.d("UDP", "S: Done."); } catch (Exception e) { Log.e("UDP", "S: Error", e); } } }; udpServerThread.start(); } catch (Exception E) { Log.e("r",E.getMessage()) ; } </code></pre> <p>so as I said, when I try it with local client(seperate thread) which sends udp trigger it works fine, but when i take this client implementation and put it on an outside real server, after UDP being sent, the phone doesn't respond to it.</p> <p>any idea?</p> <p>thanks,</p> <p>ray.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload