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 3 of 3

Thread: how to get the available server in the lan

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default how to get the available server in the lan

    i am creating a game. Now i intend to add the host lobby in my game and i was using the java socket. the result was too slow when i waiting it to return me the value
    any proffesional can help me to get the available game server ip in the lan?


  2. #2
    Junior Member
    Join Date
    Jul 2012
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: how to get the available server in the lan

    i just wanna to know how to use datagramsocket to check available server in the lan, please explain it in simply way

  3. #3
    Member
    Join Date
    Jul 2012
    Posts
    119
    Thanks
    0
    Thanked 19 Times in 19 Posts

    Default Re: how to get the available server in the lan

    Quote Originally Posted by sxlend View Post
    i just wanna to know how to use datagramsocket to check available server in the lan, please explain it in simply way
    Independent on UDP or TCP the simplest way with Socket is
    public int ping(String server, int port) {
          try {
                Socket s = new Socket(server, port);
                s.setSoLinger(true, 0);
                s.close();
                return 1; // available
          } catch (Exception e) { }
          return 0; // not available
    }

Similar Threads

  1. server and client
    By lanpan in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 24th, 2011, 08:29 AM
  2. UDP Server Client program to send and receive messages
    By Koren3 in forum Java Networking
    Replies: 1
    Last Post: September 5th, 2011, 10:16 AM
  3. Some Help For Server ..
    By JustFashion in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 27th, 2011, 04:58 AM
  4. [SOLVED] Problem in UDS client,server program
    By Koren3 in forum Java Networking
    Replies: 8
    Last Post: March 28th, 2009, 03:05 PM