Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8188451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:55:01+00:00 2026-06-07T02:55:01+00:00

I’m developing an Android 3.1 Tablet application. I’m going to use this app to

  • 0

I’m developing an Android 3.1 Tablet application.

I’m going to use this app to listen to UDP packets send by a device which is sending UDP packets to 255.255.255.255:8001 every 5 seconds.

Using desktop program Docklight scripting v1.9 I see that this device sends a 11 bytes packet every 5 seconds, by my app doesn’t receive every packet: sometimes it receives one, and sometimes it receives 5 or 6 packets at the same time.

This is my Activity:

public class UDPSocketActivity extends Activity
{
    private UDPServerThread myThread;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        int ipAddress = wifiInfo.getIpAddress();

        TextView txt = (TextView)findViewById(R.id.deviceIP);
        txt.setText(Integer.toString(ipAddress));
    }

    public void onStartClick(View view)
    {
        Log.v("UDPSocketActivity", "onClick");

        try
        {
            myThread = new UDPServerThread("X", 8001);
            myThread.start();
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

This is UDP socket thread:

public class UDPServerThread extends Thread
{
    private static final int MESSAGE_SIZE = 11;
    protected DatagramSocket socket = null;
    protected boolean end = false;

    public UDPServerThread(String serverName, int port) throws IOException
    {
        super(serverName);

        Log.v("UDPServerThread", "constructor");

        socket = new DatagramSocket(port);
        socket.setBroadcast(true);
    }

    public void run()
    {
        while (!end)
        {
            try
            {
                byte[] buf = new byte[MESSAGE_SIZE];

                // Wait an incoming message.
                DatagramPacket packet = new DatagramPacket(buf, buf.length);

                Log.v("UDServerThread", "Listenning...");

                socket.receive(packet);

                Log.v("UDServerThread", "Mensaje recibido.");
            }
            catch (IOException e)
            {
                if (!socket.isClosed())
                    e.printStackTrace();
            }
        }
    }

    public void stopServer()
    {
        Log.v("UDPServerThread", "stopServer");
        if (socket != null)
            socket.close();
        end = true;
    }
}

This is AndroidManifest.xml permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

UPDATE:
If I send a UDP packet to Tablet’s IP, e.g. UDP:192.168.1.135:8001, sometimes it receives the packet. And sometimes it receives three or four at the same time.

But if I send direct UDP packet to an HTC Desire 2.2.2 it receives all of them, but my HTC doesn’t receive broadcast packets. And I’m using the same code.

This how I am receiving UDP broadcast packets (look at the time):

07-06 12:08:56.580: V/UDServerThread(6449): Mensaje recibido.
07-06 12:08:59.655: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:02.410: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:03.230: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:03.435: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:03.745: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:03.945: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:04.460: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:04.770: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:04.975: V/UDServerThread(6449): Mensaje recibido.
07-06 12:09:46.855: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:06.005: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:06.310: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:06.515: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:06.825: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:07.335: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:07.640: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:07.845: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:10.415: V/UDServerThread(6449): Mensaje recibido.
07-06 12:10:17.065: V/UDServerThread(6449): Mensaje recibido.

What am I doing wrong? Maybe I need some custom configuration.

By the way, I am testing it on a Samsung Galaxy Tab 7.7 with Android 3.1.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:55:03+00:00Added an answer on June 7, 2026 at 2:55 am

    There was a problem with my Router.

    Note: I answer my own question because I think it’s useful for other people with the same problem (I was dealing with it by four days).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.