proc socks_monitor {nick ip} {
global hst prt sport
set hst "$ip"
set prt "1080"
catch {socket $hst $prt} sport
if {([string range $sport 0 3] == "sock") && ([lindex $sport 1] == "")} {
close $sport
putserv "privmsg Jag Yes"
return 0
}
putserv "privmsg Jag No"
close $sport
return 0
}
This script is working very well when it's a proxy/socks.
but, if it's not a proxy/socks, the eggdrop get into a big lag for a few minutes, and don't send me the message "No".
Somebody knows why? :\
Jag wrote:This script is working very well when it's a proxy/socks.
but, if it's not a proxy/socks, the eggdrop get into a big lag for a few minutes, and don't send me the message "No".
Somebody knows why? :\
This is because tcl is waiting for the tcp layer in your os to let the connection time out. The reason it takes so long is probably because the host you're trying to connect to is dropping your syn packet, so you don't get an explicit "connection refused" even though the port is not open. (or the host might be dead)
Try using -async when creating the socket. Then 'socket' will return immediately and you'll be able to set up a callback using 'fileevent' (writable) to have a second proc called when the connection succeeds/fails. This won't speed up the timeout, but allow your bot to do other things while waiting.