Well, what you've got here is a plain old window where you can open a socket connection, basically anywhere, and communicate with it. It accepts your commands and sends it through the socket and waits for responses, which it will send back to you through the window.
This is really just a trial system that will give those of you, who maybe have no idea how to communicate with sockets, a good idea of what you are getting from a server that you attempt to connect to. Enjoy!
Syntax: /socketbox
Opening Connections Example: 255.255.255.0 313
Closing Connections: [QUIT]
alias -l slb { sinfo $chr(160) }
alias -l sbox { return $sock(socketbox) }
alias -l boxnew { sockopen socketbox $1- }
alias -l boxsend { sockwrite -n SocketBox $1- }
alias -l sinfo { if ($1-) echo @SocketBox $1- }
alias -l boxclose { sockclose SocketBox | window -c @SocketBox }
alias -l SboxDo {
if ($sbox) {
sinfo -> $1-
boxsend $1-
return
}
boxnew $1 $2
}
alias socketbox {
var %s = sinfo
if ($sbox) {
var %i = $input(The SocketBox is already open. Do you wish to close the old session and start a new one?,wy,SocketBox Open)
if (!%i) return
}
boxclose
window -e @SocketBox
%s SocketBox loaded...
%s You may open a connection by typing the Hostname/IP Address and port number that you wish to connect to.
slb
%s =========================
%s Example: irc.dal.net 6667
%s =========================
slb
}
ON *:INPUT:@SocketBox:{
if (/* !iswm $1-) {
if ($1 == [QUIT]) { $iif($sock(SocketBox),sockclose socketbox) | sinfo Connection Closed! | return }
SboxDo $1-
}
}
ON *:SOCKOPEN:SocketBox: { sinfo Connection Established: $sock(socketbox).addr $sock(socketbox).port }
ON *:SOCKCLOSE:SocketBox: { sinfo Connection Terminated! }
ON *:SOCKWRITE:SocketBox: { sinfo $1- | boxsend $1- }
ON *:SOCKREAD:SocketBox:{
if ($sockerr > 0) { sinfo ERROR: $sock(SocketBox).wserr | return }
var %iData
:gather
sockread %iData
if ($sockbr == 0) return
if (!%iData) %iData = $chr(160)
sinfo %iData
goto gather
}
menu @SocketBox {
New: { if ($input(Are you sure that you wish to close this session and start a new one?,iy,Confirm New SocketBox)) { boxclose | socketbox } }
-
Close:{ if ($input(Are you sure that you wish to close this session?,wy,Confirm Close)) { boxclose } }
}