Hub Status on a Website

Which hub software is the best? Where can I find script XXX? Discuss it here...(no, this is not for advertising your hub...)

Moderator: Moderators

Locked
BigNate
Posts: 1
Joined: 2004-04-29 14:41
Location: Fargo, ND, USA
Contact:

Hub Status on a Website

Post by BigNate » 2004-04-29 14:45

Hi there

I'm new, so my apologies if this is in the wrong area.

I'd like to post the online/offline status of a hub on a website, but haven't been able to find any information on how to do it. I believe they can do it on hublist.org, but I haven't gotten a reply from anyone there.

My site is written in php, and all I need to have returned is a y/n value and I can take it from there. If anyone has anything written, I would really appreciate the help or being pointed in the right direction.

Thanks,

Nate

[edit: moved -Xan]

Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 09:32
Contact:

Post by Sedulus » 2004-04-29 16:16

hm.. I couldn't get socket_select to work :-/

so here is the ugly version..

Code: Select all

function testhub($addr, $port = 411, $timeout = 2) {
    $s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)
        or die(socket_strerror(socket_last_error()));
    socket_set_nonblock($s)
        or die(socket_strerror(socket_last_error()));
    @socket_connect($s, $addr, $port);
    for($i = 0; $i < $timeout * 2; ++$i) {
        if($buf = @socket_read($s, 6))
            if($buf == '$Lock ')
                return true;
            else
                return false;
        usleep(500000);
    }
    return false;
}

if(testhub("wza", 1418))
    echo "ONLINE";
else
    echo "OFFLINE";
make sure you have socket support in your php install (see phpinfo();)
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 09:32
Contact:

Post by Sedulus » 2004-04-29 16:29

... or alternately the prettier

Code: Select all

function testhub2($addr, $port = 411, $timeout = 2.0) {
    if(!($f = fsockopen($addr, $port, &$errno, &$errstr, $timeout)))
        return false;
    if($buf = fgets($f, 6))
        if($buf == '$Lock ')
            return true;
    return false;
}
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

Madd0g
Posts: 13
Joined: 2004-06-10 05:35

Post by Madd0g » 2004-06-10 05:36

anything like this available in ASP?
I know that there's no actual socket "action" in ASP but would I go around to doing this with xmlhttp for instance?

thanks

Locked