Script shows sockopen, sockclose, socklisten & sockwrites in a debug window, also gives reasons the commands failed... hope this helps :o)
menu @sockdata {
Socklist:.socklist
-
Close Debug:.disable #sockdebug | .window -c @sockdata
}
menu status {
-
$$iif(!$window(@sockdata), Debug Socks):.enable #sockdebug | .window -e @sockdata
-
}
#sockdebug on
alias sockopen { if (!$3) { if (!$1) .echo @sockdata 4Unable to open a socket because no name, ip or port was specified "sockopen name ip port" | elseif (!$2) .echo @sockdata 4Socket $1 4was unable to open because you have not specified a ip or port "sockopen $1 ip port" | else .echo @sockdata 4Socket $1 4was unable to open because you have not specified a port "sockopen $1- port" } | elseif ($sock($1)) .echo @sockdata 4Attempted to open socket $1 4but the name is already in use. | else { .echo @sockdata 3Opening sock $1 3to ip $2 3on port $3 | .sockopen $1- } | return }
alias sockclose { if (!$1) .echo @sockdata 4Sock close failed you have no specified a socket name. | elseif (!$sock($1)) && ($1 != *) || (* isin $1) && ($sock($1,0) < 1) .echo @sockdata 4Attempted socket close $$iif($1 == *, all, $1) 4but there was no match(s). | else { .echo @sockdata 3Socket close $1 3, $$iif($1 == *, $sock(*,0) match closed., $$iif(* isin $1, $sock($1,0) match closed., 3match was successfully closed.)) | .sockclose $1 } | return }
alias socklisten { if ($sock($1)) .echo @sockdata 4Attempted to listen on socket $1 4but the name is already in use. | elseif ($2 !isnum 1-65535) .echo @sockdata 4Attempted socket listen $1 4failed because your specified port is $$iif($2 isnum 65535-, out of range, invalid) "socklisten $1 1-65535" | elseif (!$2) { if (!$1) .echo @sockdata 4Socket listen failed you have no specified a socket name or port "socklisten name port" | else .echo @sockdata 4Sock listen failed you have no specified a port "socklisten $1 port" } | else { .echo @sockdata 3Socket $1 3listening on port $2 | .socklisten $1- } | return }
alias sockwrite { if (!$1) { .echo @sockdata 4Sockwrite failed you have no specified a switch, socket name or data. "sockwrite switch name data" | return } | if ($1 !isin -t -n -tn -nt) && (!$sock($1)) && (!$sock($1,1)) { .echo @sockdata 4Sockwrite to $1 4failed because the socket name does not exist ( $+ $2- $+ ) | return } | elseif ($1 isin -t -n -tn -nt) { if (!$2) { .echo @sockdata 4Sockwrite failed you have specified a switch but no socket name or data. "sockwrite $1 name data" | return } | elseif (!$sock($2)) { .echo @sockdata 4Sockwrite to $2 4failed because the socket name does not exist. ( $+ $3- $+ 4) | return } | elseif (!$3) { .echo @sockdata 4Sockwrite failed you have specified a switch & socket name but no data. "sockwrite $1- data" | return } } | .echo @sockdata 3Sockwrite $1- | .sockwrite $1- | return }
#sockdebug end