[APK] Server status in android

Discussion in 'Off-Topic' started by Hipster, Oct 28, 2017.

  1. Hipster

    Hipster Zombie

    Messages:
    203
    Hey I've been trying socket.connect to see if my server is online or not via android studio, but it seems to timeout always, what am i doing wrong?
     
  2. Kyd

    Kyd Zombie Pigman

    Messages:
    682
    Can you provide code you used?
     
  3. Hipster

    Hipster Zombie

    Messages:
    203
    Code:
    SocketAddress sockaddr = new InetSocketAddress(serverIp, 19132);
    Socket socket = new Socket();
    socket.connect(sockaddr, 10000);
    This is in asynctask in try{}
     
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    682
    Try this
    Code:
    public boolean isServerOnline(string serverIp){
    Socket s = null;
       try{
            s = new Socket(serverIp, port);
            return true;
        }catch (Exception e){
            return false;
        }
    }
    
     
  5. Hipster

    Hipster Zombie

    Messages:
    203
    How to get player count too? nothings working
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    682
    Have you enabled query in server.properties?
     
  7. Hipster

    Hipster Zombie

    Messages:
    203
    it works now! thank you
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,915
    GitHub:
    sof3
    Isn't that a TCP socket?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.