diff options
author | dgp <dgp@users.sourceforge.net> | 2016-06-16 14:48:35 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-06-16 14:48:35 (GMT) |
commit | b700360ad9501defb0b1e2d86353ac8d0db8eef4 (patch) | |
tree | 8b3bcb3adb8bd2eb44bcf16bb091722274e03e9e /tests/remote.tcl | |
parent | c755ef08151343eb145710489f8c999edbef15ff (diff) | |
parent | 296aebbd6ee092a25741684fa37ee31ef5a3e222 (diff) | |
download | tcl-b700360ad9501defb0b1e2d86353ac8d0db8eef4.zip tcl-b700360ad9501defb0b1e2d86353ac8d0db8eef4.tar.gz tcl-b700360ad9501defb0b1e2d86353ac8d0db8eef4.tar.bz2 |
Merge up to the 8.6.0 release.
Diffstat (limited to 'tests/remote.tcl')
-rw-r--r-- | tests/remote.tcl | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/tests/remote.tcl b/tests/remote.tcl index 005f2df..097e41f 100644 --- a/tests/remote.tcl +++ b/tests/remote.tcl @@ -8,8 +8,6 @@ # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -# -# RCS: @(#) $Id: remote.tcl,v 1.3 1999/04/16 00:47:33 stanton Exp $ # Initialize message delimitor @@ -32,11 +30,9 @@ proc __doCommands__ {l s} { puts "---" } set callerSocket $s - if {[catch {uplevel #0 $l} msg]} { - list error $msg - } else { - list success $msg - } + set ::errorInfo "" + set code [catch {uplevel "#0" $l} msg] + return [list $code $::errorInfo $msg] } proc __readAndExecute__ {s} { @@ -44,10 +40,9 @@ proc __readAndExecute__ {s} { set l [gets $s] if {[string compare $l "--Marker--Marker--Marker--"] == 0} { - if {[info exists command($s)]} { - puts $s [list error incomplete_command] - } + puts $s [__doCommands__ $command($s) $s] puts $s "--Marker--Marker--Marker--" + set command($s) "" return } if {[string compare $l ""] == 0} { @@ -59,28 +54,26 @@ proc __readAndExecute__ {s} { } return } - append command($s) $l "\n" - if {[info complete $command($s)]} { - set cmds $command($s) - unset command($s) - puts $s [__doCommands__ $cmds $s] - } if {[eof $s]} { if {$VERBOSE} { puts "Server closing $s, eof from client" } close $s + unset command($s) + return } + append command($s) $l "\n" } proc __accept__ {s a p} { - global VERBOSE + global command VERBOSE if {$VERBOSE} { puts "Server accepts new connection from $a:$p on $s" } - fileevent $s readable [list __readAndExecute__ $s] + set command($s) "" fconfigure $s -buffering line -translation crlf + fileevent $s readable [list __readAndExecute__ $s] } set serverIsSilent 0 @@ -153,20 +146,14 @@ if {$serverIsSilent == 0} { flush stdout } +proc getPort sock { + lindex [fconfigure $sock -sockname] 2 +} + if {[catch {set serverSocket \ [socket -myaddr $serverAddress -server __accept__ $serverPort]} msg]} { puts "Server on $serverAddress:$serverPort cannot start: $msg" } else { + puts ready vwait __server_wait_variable__ } - - - - - - - - - - - |