1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

[APK] Server status in android

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

  1. Hipster

    Hipster Zombie

    Messages:
    214
    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:
    678
    GitHub:
    boi1216
    Can you provide code you used?
     
  3. Hipster

    Hipster Zombie

    Messages:
    214
    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:
    678
    GitHub:
    boi1216
    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:
    214
    How to get player count too? nothings working
     
  6. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Have you enabled query in server.properties?
     
  7. Hipster

    Hipster Zombie

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

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Isn't that a TCP socket?
     
  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.