I've found /sockaccepting and /sockclosing in the same socklisten event produces the same effect had you not /sockaccept'ed in the first place:
alias test {
if $sock(listen) { sockclose listen }
socklisten -d 127.0.0.1 listen 12345
if $sock(open) { sockclose open }
sockopen open 127.0.0.1 12345
}
on *:socklisten:listen:{
if $sock(accept) { sockclose accept }
sockaccept accept
sockclose accept
sockclose listen
}
on *:sockopen:open:{
if $sockerr { echo -s error: $sock($sockname).wsmsg }
else { echo -s connected normally }
}
on *:sockclose:open:{ echo -s closed: $iif($sockerr,$sock($sockname).wsmsg,no error) }
connected normally
closed: no error
After /test'ing that, comment out these lines:
;if $sock(accept) { sockclose accept }
;sockaccept accept
;sockclose accept
And /test again.
connected normally
closed: no error
Your mileage may vary however.