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

  • Home
  • SEARCH
  • 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 6003103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:04:26+00:00 2026-05-23T01:04:26+00:00

I have an issue with broadcasting Datagram packets from one Android phone to the

  • 0

I have an issue with broadcasting Datagram packets from one Android phone to the next.

I have set up my application to be able to use 2 different Datagram Sockets. This all works well, and I am able to switch between the Sockets just fine.

I use 2 phones to test the application, as well as a PC based application that is able to communicate with my application. When I try to broadcast Datagram packets from 1 of the 2 phones, the PC application reacts just fine, but the other phone doesn’t respond at all. The same happens when I try it with the other phone.

But here’s the catch: whenever I try to broadcast from the PC based application, both phones respond. (???)

Both devices and the PC application are set to use the same broadcast address for sending. Yet it doesn’t seem that the phone’s accept the broadcast of the other. I have confirmed that they do get a broadcast response from themselves when they are broadcasting, which is correct obviously.

The methods I use to initialise and update the broadcast socket is stated below.

private void initBroadcastSocket(Inet4Address address, int port){
    try {
        mBroadcastSocket = new DatagramSocket(port, address);
        mBroadcastSocket.setBroadcast(true);
        mBroadcastSocket.setSoTimeout(SOCKET_TIME_OUT);
    } catch (IOException ioe) {
        Log.e(TAG, "Exception occurred while initializing BroadcastSocket: " + ioe.toString());
    }
    if(mBroadcastSocket != null){
        Log.d(TAG, "BroadcastSocket initially set to " + mBroadcastSocket.getLocalAddress() +
                    ":" + mBroadcastSocket.getLocalPort());
    }
}

public synchronized void updateBroadcastSocket(Inet4Address address, int port){
    // Temporarily suspend the listening Thread.
    ...
    // If the socket is open, close it.
    if(mBroadcastSocket != null){
        mBroadcastSocket.close();
        mBroadcastSocket = null;
    }
    // Create new socket with the passed values.
    try {
        mBroadcastSocket = new DatagramSocket(port, address);
        mBroadcastSocket.setBroadcast(true);
        mBroadcastSocket.setSoTimeout(SOCKET_TIME_OUT);
    } catch (SocketException se) {
        Log.e(TAG, "Exception occured while updating BroadcastSocket: " + se.toString());
    }
    // Log new address and port.
    ...
    // Continue the listening Thread.
    ...
}

If anyone finds a flaw in my code, please elaborate.

  • 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-05-23T01:04:27+00:00Added an answer on May 23, 2026 at 1:04 am

    Issue is both Android devices have the same IP-Address (somehow). I am trying to fix this now.

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

Sidebar

Related Questions

We have an issue using the PEAR libraries on Windows from PHP . Pear
We have an issue related to a Java application running under a (rather old)
I have an issue with using AWK to simply remove a field from a
Much of my sql code is generated (from POD). Now i have issue where
I have an issue that is driving me a bit nuts: Using a UserProfileManager
We have an issue on our page whereby the first time a button posts
I have some issue with a Perl script. It modifies the content of a
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
We have an issue with the way we are creating a Mutex . The
I currently have an issue in my DLR language implementation where subsequent calls to

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.