Results 1 to 2 of 2
  1. #1
    sushil is offline Member
    Join Date
    Oct 2009
    Rep Power

    Exclamation finding the number of computer connected in LAN

    I am facing problem will performing my project

    problem :1) finding the number of computer connected in LAN via java

    2)How to broadcast message to all computer connected in LAN

    if anybody know the solution plz help me out

  2. #2
    Bluefox815 is offline Member
    Join Date
    Feb 2008
    Oregon, USA
    Rep Power


    By computer number, I assume you mean IP address.

    When you receive a connection from a client using a object, you can use the getInetAddress() method in Socket to get an InetAddress object and then the getAddress() method in InetAddress to get an array of bytes.

    Java Code:
    ServerSocket serverSocket;
    Socket client;
    byte[] address;
    try {
        serverSocket = new ServerSocket(4444); // open a port for listening
        client = serverSocket.accept(); // listen on the specified port
        address = client.getInetAddress().getAddress();
    } catch (IOException ioe) {
        System.out.println("Handle IOException here.");
    This code snippet should give you a basic idea of how to get the IP address of a host once it has connected. I did leave out how to broadcast the message, though. If you posted some code then I might be able to help you a little more.

Similar Threads

  1. Finding the largest number in an array
    By starchildren3317 in forum New To Java
    Replies: 14
    Last Post: 11-03-2010, 07:49 AM
  2. I am new, can anyone help me in Computer Vision?
    By howardL in forum Introductions
    Replies: 0
    Last Post: 04-23-2009, 10:37 AM
  3. finding length on a number
    By thekrazykid in forum New To Java
    Replies: 8
    Last Post: 12-12-2008, 09:07 PM
  4. Finding the highest number
    By jigglywiggly in forum New To Java
    Replies: 7
    Last Post: 11-04-2008, 09:14 AM
  5. Replies: 2
    Last Post: 08-08-2007, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts