2017-04-25 14:41:48 +02:00
|
|
|
#-------------------------------------------------------------
|
|
|
|
|
# socketcmd.tcl ---
|
|
|
|
|
#
|
|
|
|
|
# Method to pass commands to magic through a socket
|
|
|
|
|
# From the client side, use "set chan [socket 0.0.0.0 12946]"
|
|
|
|
|
# and pass commands with "puts $chan {magic command}" and
|
|
|
|
|
# "flush $chan".
|
|
|
|
|
#-------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
set commPort 12946
|
|
|
|
|
|
|
|
|
|
proc handleComm {chan} {
|
|
|
|
|
if {[gets $chan line] >= 0} {
|
|
|
|
|
puts $line
|
|
|
|
|
eval $line
|
|
|
|
|
}
|
|
|
|
|
if {[eof $chan]} {
|
|
|
|
|
close $chan
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proc acceptComm {chan addr port} {
|
2020-05-23 23:13:14 +02:00
|
|
|
fconfigure $chan -blocking 0 -buffering line -translation crlf
|
2017-04-25 14:41:48 +02:00
|
|
|
fileevent $chan readable [list handleComm $chan]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
socket -server acceptComm $commPort
|