I can only imagine this bug is not limited to socket events nor $sockname, but using /url within at least sockread and sockclose causes $sockname to be unset. I have not tested beyond these cases. I've also noted that context is switched after the /url call. The sockclose event runs before the next line in sockread after /url. I can somewhat understand how identifiers would be lost with this context switch, but not why the switch happens in the first place.
Workaround for possible side effects due to context swtich - always call /url from a timer?
alias test {
sockopen -e url_sock www.google.com 443
}
on *:sockopen:url_sock:{
sockwrite -n $sockname GET / HTTP/1.0
sockwrite -n $sockname Host: google.com
sockwrite -n $sockname User-Agent: mIRC
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
on *:sockread:url_sock:{
sockread -f %read
if (%read == The document has moved) {
echo 4 -ag sockread: $!sockname = $sockname
url www.yahoo.com
echo 4 -ag sockread: $!sockname = $sockname
}
}
on *:sockclose:url_sock:{
echo 3 -ag sockclose: $!sockname = $sockname
url www.yahoo.com
echo 3 -ag sockclose: $!sockname = $sockname
}
sockread: $sockname = url_sock
sockclose: $sockname = url_sock
sockclose: $sockname =
sockread: $sockname =