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

    Exclamation finding the number of computer connected in LAN

    hi
    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
    Location
    Oregon, USA
    Posts
    49
    Rep Power
    0

    Default

    By computer number, I assume you mean IP address.

    When you receive a connection from a client using a java.net.Socket 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.

    Example:
    Java Code:
    import java.net.*;
    
    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, 06: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, 09:37 AM
  3. finding length on a number
    By thekrazykid in forum New To Java
    Replies: 8
    Last Post: 12-12-2008, 08:07 PM
  4. Finding the highest number
    By jigglywiggly in forum New To Java
    Replies: 7
    Last Post: 11-04-2008, 08:14 AM
  5. Replies: 2
    Last Post: 08-08-2007, 10: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
  •