All pastes #144955 Raw Edit

evestatus

public text v1 · immutable
#144955 ·published 2006-08-22 19:24 UTC
rendered paste body
//
// EVEstatus
// Copyright (C) 2006 Anders Bergh
//

import std.stdio;
import std.socket;

int main (char[][] args) {
    static char[] data = [0x23, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00,
      0x00, 0x14, 0x06, 0x04, 0xE8, 0x99, 0x02, 0x00,
      0x05, 0x8B, 0x00, 0x08, 0x0A, 0xCD, 0xCC, 0xCC,
      0xCC, 0xCC, 0xCC, 0x00, 0x40, 0x05, 0x49, 0x0F,
      0x10, 0x05, 0x42, 0x6C, 0x6F, 0x6F, 0x64];

    char[] server = "87.237.38.200";
    ushort port = 26000;

    bool online = false;
    int users = 0;

    void printd () {
        if (online)
            writefln("Server status: Online, %d users", users);
        else
            writefln("Server status: Offline, %d users", users);
    }

    auto Socket sock = new TcpSocket(new InternetAddress(server, port));

    char[256] response;

    sock.send(response);

    int bytes = sock.receive(response);

    if (bytes > 21) {
        users = response[21] * 256 + response[20];
        online = true;
    } else {
        users = 0;
        online = false;
    }

    printd();

    return 0;
}