Are you sure on sockopen is meant to trigger when the negociation fails?
I cannot get on sockopen to trigger a second time with $sockerr set when the negotiation fails.
When I try to fake a server having SSL capability (socklisten -e has been suggested!), the client trying to negociate with /sockopen -t does not get its socket triggering on sockopen a second time, instead on sockclose triggers with $sockerr set to 5 (winsock error is 10101 host disconnected).

on *:socklisten:listen:if (!$sockerr) sockaccept client1 | sockclose listen

alias teststarttls socklisten -d 0.0.0.0 listen $1 | sockopen -d 0.0.0.0 client 127.0.0.1 $1

on *:sockopen:client:{
if (!$sockerr) {
if (!$sock(client).starttls) {
sockopen -t client
echo -sg here start negoc
}
else echo -sg starttls negoc success
}
elseif ($sock(client).starttls) echo -sg starttls fail $sockerr $sock(client).wsmsg
else echo -sg cannot connect initially
}

on *:sockread:client1:{
if ($sockerr) {
echo -sg client socket read error!! $sock(client).wsmsg
return
}
echo -sg $sock($sockname).rq
sockread $sock(client).rq &a
if (!$sockbr) return
else echo -sg read $sockbr : $bvar(&a,1-)
}
on *:sockclose:client:echo -sg sockclose $sockerr $sock(client).wsmsg
/teststarttls 8080
You'll have to close the sockets client1 manually and maybe more if you need to test more than once.
After /sockopen -t client, the server will receive data, at this point I copy the data and do //bset &a -1 <paste the bytes here> | sockwrite client1 &a


#mircscripting @ irc.swiftirc.net == the best mIRC help channel