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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:39:03+00:00 2026-05-26T03:39:03+00:00

We are currently working on a client-server game in java. We used DatagramSocket to

  • 0

We are currently working on a client-server game in java. We used DatagramSocket to perform communications between client and server. Inorder for the client to communicate to server, he must know the LAN ip address of the machine where the server is running. Multiple clients can connect to server, we used a thread for each client.

Our problem is we wanted to show a list of LAN ip addresses of running servers to the clients so that it is easier for them to find servers like slist command in Counter Strike. Our solution is the client sends a message to all computers connected to the network and if a computer with a running server receives it, it will reply a message back to the client and then we print it’s ip address in the client.

InetAddress localHost = Inet4Address.getLocalHost();
String myIP=localHost.toString().substring(localHost.toString().lastIndexOf("/")+1);

//split myIP into 4 parts (part1.part2.part3.part4)
//use the first part to check the class of the network (A, B, or C)

//I'll skip to C
if(part1>=1 && part1<=126) //A
else if(part1>=128 && part1<=191) //B
else if(part1>=192 && part1<=223){
    String network= part1 + "." + part2 + "." part3;
    String guess;
    for(i=0;i<255;i++){
         guess = network+"."+i;
         serverSend(guess); //send the message to an ip address in the network
    }
}

It works fine for network in class C but for B and A, it is too slow. We assume the worst-case subnet mask for B and A which is 255.255.0.0 (65,025 iterations) and 255.0.0.0 (16,581,375).

Does anyone got a better solution to this? thank you 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-26T03:39:03+00:00Added an answer on May 26, 2026 at 3:39 am

    what you are looking for is broadcast.

    I have gathered a tutorial for you:
    http://download.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html

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

Sidebar

Related Questions

I'm currently working on an emulation server for a flash-client based game, which has
I am working on an IMAP client using java mail. We currently have a
Currently I'm working on a Server-Client system which will be the backbone of my
I am currently working on a silverlight client, making use of a web server,
I'm working on a multiplayer flash game. The server informs each client what other
Im currently working on an RMI client that will talk to an RMI server
I'm working on a little client that interfaces with a game server. The server
I am working on a client-server application in Java which is going to use
Currently I'm working on a C/C++ cross-platform client/server software. I'm very experienced developer when
I'm currently working on a small client/server project that uses CORBA and I am

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.