@@ -195,7 +195,7 @@ proc newconn {chan addr port} {
proc main-daemon {which setup} {
global c argv
- set host $c(${which}DaemonHost)
+ catch { set host $c(${which}DaemonHost) }
set port $c(${which}DaemonPort)
foreach arg $argv {
@@ -210,12 +210,21 @@ proc main-daemon {which setup} {
fconfigure stdout -buffering line
fconfigure stderr -buffering none
- log "starting $host:$port"
+ set desc $port
+
+ set sockcmd {socket -server newconn}
+ if {[info exists host]} {
+ set desc "$host:$port"
+ lappend sockcmd [list -myaddr $host]
+ }
+ lappend sockcmd $port
+
+ log "starting $desc"
uplevel 1 $setup
- socket -server newconn -myaddr $host $port
- log "listening $host:$port"
+ eval $sockcmd
+ log "listening $desc"
vwait forever
}