Merge pull request #143 from gsomlo/gls-gui-getmyip

gui: exec.tcl: cache local IP address across calls to getMyIP
This commit is contained in:
Jeff Ahrenholz 2018-02-22 07:55:27 -08:00 committed by GitHub
commit 5e56138869
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -782,14 +782,17 @@ proc manageCPUwindow {xpos ypos start} {
} }
proc getMyIP { } { proc getMyIP { } {
if { [catch {set theServer [socket -server none -myaddr \ variable myIP
[info hostname] 0]} ] } { if { ![info exists myIP] } {
return "127.0.0.1" if { [catch {set theServer [socket -server none \
-myaddr [info hostname] 0]} ] } {
set myIP "127.0.0.1"
} else {
set myIP [lindex [fconfigure $theServer -sockname] 0]
close $theServer
}
} }
set myIP [lindex [fconfigure $theServer -sockname] 0]
close $theServer
return $myIP return $myIP
} }
# display all values stored in cpu usage history for each server # display all values stored in cpu usage history for each server