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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:49:46+00:00 2026-05-18T20:49:46+00:00

I am currently writing a client-server application and I ask myself if there is

  • 0

I am currently writing a client-server application and I ask myself if there is a better way to find a server in the local network then going trough all the available IP addresses and see if the correct answer is supplied?

  • 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-18T20:49:47+00:00Added an answer on May 18, 2026 at 8:49 pm

    You might want to look into UDP broadcasts, where your server announces itself and the phone listens for the broadcasts.


    There is an example from the Boxee remote project, quoted below.

    Getting the Broadcast Address

    You need to access the wifi manager to get the DHCP info and construct a broadcast address from that:

    InetAddress getBroadcastAddress() throws IOException {
        WifiManager wifi = mContext.getSystemService(Context.WIFI_SERVICE);
        DhcpInfo dhcp = wifi.getDhcpInfo();
        // handle null somehow
    
        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);
    }
    

    Sending and Receiving UDP Broadcast Packets

    Having constructed the broadcast address, things work as normal. The following code would send the string data over broadcast and then wait for a response:

    DatagramSocket socket = new DatagramSocket(PORT);
    socket.setBroadcast(true);
    DatagramPacket packet = new DatagramPacket(data.getBytes(), data.length(),
        getBroadcastAddress(), DISCOVERY_PORT);
    socket.send(packet);
    
    byte[] buf = new byte[1024];
    DatagramPacket packet = new DatagramPacket(buf, buf.length);
    socket.receive(packet);
    

    You could also look into Bonjour/zeroconf, and there is a Java implementation that should work on Android.

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

Sidebar

Related Questions

I am currently writing an application having a client server architecture. The client is
I'm currently writing a jdbc client-server socket application in java. I've been having a
I'm writing a client-server application to be used in a computer lab and act
I am writing a pyQt client-server application which restarts/shutdowns PCs remotely. The receivers are
I'm writing a client and server application. Right now I've just been developing it
I am writing a .NET Remoting application. I have my dll, server, and client
I am writing (trying) a client server application with these 3 layers: Client and
For learning purposes I am writing a socket based client/server application. I have designed
For learning purposes I am writing a socket based client/server application. I have designed
I'm currently writing a client in ActionScript 3 that talks to a Red5 application/media

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.