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 8953837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:11:18+00:00 2026-06-15T14:11:18+00:00

I want to broadcast from an android device which acts as a hotspot, but

  • 0

I want to broadcast from an android device which acts as a hotspot, but using 255.255.255.255 does not work as UDP broadcast in android. But 192.168.1.255 this broadcast address works. When I check the IP address of my device its shows 192.168.1.4.

Now how to calculate address 192.168.1.255 from this address?

  • 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-15T14:11:19+00:00Added an answer on June 15, 2026 at 2:11 pm

    Well, if you have the broadcasting worked out and only need to change the last byte of the address to 255, you can do the following:

    String getBroadcastAddress( final String address ) throws UnknownHostException {
        InetAddress addr = InetAddress.getByName( address );
        if( InetAddress instanceof Inet4Address ) {
            byte[] bytes = addr.getAddress();
            bytes[3] = 255;
            return InetAddress.getByAddress( bytes ).getHostAddress();
         } else {
             ... deal with ipv6
         }
    }
    

    Pulling the broadcast address directly from the NetworkInterface, results in this code:

    public static String getBroadcast() throws SocketException {
        System.setProperty("java.net.preferIPv4Stack", "true");
        for( Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements(); ) {
            NetworkInterface nif = interfaces.nextElement();
            if( !nif.isLoopback() ) {
                for( InterfaceAddress addr : nif.getInterfaceAddresses() ) {
                    return addr.getBroadcast().toString().substring(1);
                }
            }
        }
        return null;
    }
    

    You may have to sift through the NetworkInterface to find the one corresponding to the internal ip.

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

Sidebar

Related Questions

I want to broadcast simple short message from Android device to iOS and Android
When exactly does an app receive an INSTALL_REFERRER broadcast from Android Market? Can I
I want to broadcast messages locally to many application. For that I thought UDP
What I want is to broadcast an android camera video to remote locations, for
I have a broadcast receiver which receive an internet state changes. I want to
I've use Parse to give my iOS and Android App notifications. But I want
Using C#, does broadcasting over UDP repeatedly send its packet, or just once? I've
I want to trigger a Broadcast receiver from the notification. When I click on
I am using ActionBar Tabs in Android 4 . I have 5 Broadcast receivers
I want to track the number of messages that are sent from an android

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.