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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:34:46+00:00 2026-05-25T12:34:46+00:00

I am in the early stages of developing a cross platform UDP server client.

  • 0

I am in the early stages of developing a cross platform UDP server client. In my case, the clients send a broadcast to an android phone that they are connected to, via the mobile hotspot option.

I am currently testing this by having the server and client on the same device. However, I only know how to get the broadcast address, thanks to a boxee remote app.

Is anyone aware of a way to do the same as the code below, but to get the Mobile network broadcast address?

So, here is the code:

InetAddress getBroadcastAdd(Context context) throws IOException {
    WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    DhcpInfo dhcp = wifi.getDhcpInfo();

    int broadcast = (dhcp.ipAddress & dhcp.netmask) | ~dhcp.netmask;
    byte[] quads = new byte[4];
    for (int k = 0; k < 4; k++)
      quads[k] = (byte) ((broadcast >> k * 8) & 0xFF);
    return InetAddress.getByAddress(quads);
}

For the eagle eyed readers, you will have gathered that I actually do not need this code for the app to work as the other devices will get a broadcast address from the wifi but I do need to do some testing on this one device first.

Thanks in advance!

  • 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-25T12:34:47+00:00Added an answer on May 25, 2026 at 12:34 pm

    Most networks (Wifi and 3G) use NAT. NAT allows outbound connections, but prevents inbound (internet to device) connections.

    When your server and device are both on the same local network (wifi), then this works as you are not traversing NAT gateway.

    Rationale: what you are trying to do (connecting from internet to device) will not work in most networks.

    Update

    If your devices are both on same local network then you can use a standardised way of advertising/discovering services: Bonjour aka Zeroconf. There is java implementation that is reported to work on android: http://jmdns.sourceforge.net/

    Also see http://home.heeere.com/tech-androidjmdns.html

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

Sidebar

Related Questions

I'm in the early stages of a web application that will contain a client
I'm in the early stages of writing an app that will need to broadcast
I am currently in the early stages of developing a couple web applications, I
Currently in the early stages of developing a very large project using ASP.Net MVC.
I am in the early stages of developing a database-driven system and the largest
I am in the early stages of developing a sports statistics website (ultimate frisbee)
I'm in early (pre-coding) stages of developing a mobile web application using jQuery Mobile
I'm in the early stages of a note-taking application for android and I'm hoping
I am in the early stages of developing an Azure web project which will
I am in the early stages of planning and designing a custom accounting application

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.