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:
commit
5e56138869
1 changed files with 9 additions and 6 deletions
15
gui/exec.tcl
15
gui/exec.tcl
|
@ -782,14 +782,17 @@ proc manageCPUwindow {xpos ypos start} {
|
|||
}
|
||||
|
||||
proc getMyIP { } {
|
||||
if { [catch {set theServer [socket -server none -myaddr \
|
||||
[info hostname] 0]} ] } {
|
||||
return "127.0.0.1"
|
||||
variable myIP
|
||||
if { ![info exists myIP] } {
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
# display all values stored in cpu usage history for each server
|
||||
|
|
Loading…
Reference in a new issue