I am a noob in tcl and never scripted any tcl scripts before but I also have no time to learn TCL since I follow college and work on my website alott.
I am looking for a tcl script that will check if a server+port is online.
Currently I have a website version of it with using the php fsockopen commando, look here: http://hbr.relaxz.net/?page=status
And i was wondering how to make it a tcl eggdrop addon so people can use a commando like !online [number or server name] to see if it is online or now.
proc test_host_port {host port callback} {
# first resolve the host to an ip (async)
dnslookup $host [list host_resolved $callback $port]
}
proc host_resolved {callback port ip host success} {
# see if we have a valid ip
if {![string compare $ip "0.0.0.0"]} {
eval $callback [list $host $port 0]
return 1
}
# now open an async socket
set sock [socket -async $ip $port]
fileevent $sock writable [list sock_result $callback $host $port $sock]
}
proc sock_result {callback host port sock} {
set err [fconfigure $sock -error]
close $sock
eval $callback [list $host $port $err]
}