0 Replies - 268 Views - Last Post: 29 November 2015 - 11:03 AM

#1 benbenyakir   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 18-November 15

Trying to receive udp broadcast but getting exception why ?

Posted 29 November 2015 - 11:03 AM

What i'm trying to do is to broadcast over my network at home from my pc using c# a string my pc ip address as a string.
The broadcasting is working i guess since i checked and tried to receive it with c# and it worked on same machine.
But now i'm trying to receive the string on my android device using android-studio and java.
The problem is all the methods on java i tried i got exception.
I'm not sure if to post here the c# broadcast code so i will post for now only the java receive code:

private void Listen()
    {
        DatagramSocket UDP_packet = null;
        try
        {
            UDP_packet = new DatagramSocket(15000);
        } catch (SocketException e)
        {
            e.printStackTrace();
        }
        //receive UDP packet
        boolean gogo = false;
        while (!gogo) {
            byte[] buffer = new byte[1024];
            DatagramPacket incoming = new DatagramPacket(buffer, buffer.length);
            try
            {
                UDP_packet.receive(incoming);
            } catch (IOException e)
            {
                e.printStackTrace();
            }
            String message = null;
            try
            {
                message = new String(incoming.getData(), 0, incoming.getLength(), "UTF-8");
            } catch (UnsupportedEncodingException e)
            {
                e.printStackTrace();
            }
        }
        UDP_packet.close();
    }



When it's getting to the line that make an instance for the DatagramSocket the program just hang nothing happen.

UDP_packet = new DatagramSocket(15000);


Then i looked on the LogCat and saw this exception message:



11-29 19:52:23.428 3324-13652/? E/WhatsApp﹕ IOException on LL_I W [1102:WhatsApp Worker #76] ==== logfile level=3 tz=+0200 ====
java.nio.channels.FileLockInterruptionException
at java.nio.FileChannelImpl.lock(FileChannelImpl.java:172)
at java.nio.channels.FileChannel.lock(FileChannel.java:185)
at com.whatsapp.util.Log.a(Log.java:96)
at com.whatsapp.util.Log.b(Log.java:36)
at com.whatsapp.util.Log.a(Log.java:23)
at com.whatsapp.util.Log.a(Log.java:205)
at com.whatsapp.util.Log.b(Log.java:36)
at com.whatsapp.util.Log.i(Log.java:162)
at com.whatsapp.mc.a(mc.java:116)
at com.whatsapp.mc.c(mc.java:293)
at com.whatsapp.am9.a(am9.java:11)
at com.whatsapp.c8.a(c8.java:16)
at com.whatsapp.c8.doInBackground(c8.java:15)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at com.whatsapp.util.co.run(co.java:4)
at java.lang.Thread.run(Thread.java:818)
11-29 19:52:23.429 3324-13652/? E/WhatsApp﹕ IOException on LL_I W [1102:WhatsApp Worker #76] 513 contacts selected for picker (context=BROADCAST) | time: 198
java.nio.channels.ClosedChannelException
at java.nio.FileChannelImpl.checkOpen(FileChannelImpl.java:74)
at java.nio.FileChannelImpl.lock(FileChannelImpl.java:160)
at java.nio.channels.FileChannel.lock(FileChannel.java:185)
at com.whatsapp.util.Log.a(Log.java:96)
at com.whatsapp.util.Log.b(Log.java:36)
at com.whatsapp.util.Log.i(Log.java:162)
at com.whatsapp.mc.a(mc.java:116)
at com.whatsapp.mc.c(mc.java:293)
at com.whatsapp.am9.a(am9.java:11)
at com.whatsapp.c8.a(c8.java:16)
at com.whatsapp.c8.doInBackground(c8.java:15)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at com.whatsapp.util.co.run(co.java:4)
at java.lang.Thread.run(Thread.java:818)


I see LockedFile and i wonder what file is locked ? Then ClosedChannel ?

Is This A Good Question/Topic? 0
  • +

Page 1 of 1