Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Regarding socket programming

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Regarding socket programming

    how to know how many computers are connected in LAN by using java?


  2. #2
    Junior Member
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Regarding socket programming

    InetAddress localhost=InetAddress.getLocalHost();
    byte[] ip=localhost.getAddress();
    for(int i=0;i<=50;i++)
    {
    ip[3]=(byte)i;
    InetAddress add=InetAddress.getByAddress(ip);
    if(!add.getHostAddress().equals(add.getHostName()) )
    System.out.println(add);
    }

    value of i can vary from 0-255

Similar Threads

  1. Socket Programming over the Internet
    By djmaxtor in forum Java Networking
    Replies: 6
    Last Post: July 24th, 2012, 04:21 AM
  2. socket programming
    By advjava in forum Member Introductions
    Replies: 3
    Last Post: April 5th, 2011, 11:21 PM
  3. [SOLVED] Problem in socket programming
    By sinni in forum Java Networking
    Replies: 1
    Last Post: March 15th, 2011, 10:26 AM
  4. [SOLVED] Socket Programming Problem
    By relixus in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 9th, 2010, 10:35 PM