setup_tcp_bespice: if port 0 is given let TCL find a free port

This commit is contained in:
stefan schippers 2023-11-01 02:23:21 +01:00
parent 18f337734d
commit 1955d6d386
2 changed files with 22 additions and 18 deletions

View File

@ -1973,7 +1973,7 @@ int rstate; /* (reduced state, without ShiftMask) */
if(xctx->semaphore >= 2) break;
edit_property(1);break;
}
if(key=='i' && rstate==0) /* descend to symbol */
if(key=='i' && rstate==0) /* descend to symbol */
{
if(xctx->semaphore >= 2) break;
descend_symbol();break;

View File

@ -4813,7 +4813,7 @@ proc alert_ {txtlabel {position +200+300} {nowait {0}} {yesno 0}} {
toplevel .alert -class Dialog
wm title .alert {Alert}
wm transient .alert .
set X [expr {[winfo pointerx .alert] - 60}]
set X [expr {[winfo pointerx .alert] - 70}]
set Y [expr {[winfo pointery .alert] - 60}]
if { [string compare $position ""] != 0 } {
wm geometry .alert $position
@ -7288,7 +7288,7 @@ proc setup_tcp_xschem { {port_number {}} } {
if {$port_number ne {}} { set xschem_listen_port $port_number}
if { [info exists xschem_listen_port] && ($xschem_listen_port ne {}) } {
if {[catch {socket -server xschem_server $xschem_listen_port} err]} {
puts "setup_tcp_xschem: problems listening to TCP port: $xschem_listen_port"
puts "setup_tcp_xschem: problems finding a free TCP port"
puts $err
return 0
} else {
@ -7310,27 +7310,31 @@ proc setup_tcp_bespice {} {
# We will attempt to open port $bespice_listen_port ... $bespice_listen_port + 1000 this should succeed ...
# We need to make this attempt as several instances of xschem / bespice might be running.
# Each of these instances needs it's own server listening on a dedicated port.
# The variable $bespice_listen_port is passed to bespice wave when the application is started in the function "set_sim_defaults()".
set port $bespice_listen_port
set last_port [expr $port + 1000]
while { $port < $last_port } {
if {[catch {socket -server bespice_server $port} err]} {
# failed => increment port
incr port
} else {
# succeded => set $bespice_listen_port and socket connection for communication
puts stderr "setup_tcp_bespice: success : listening to TCP port: $port"
set bespice_server_getdata(server) $err
set bespice_listen_port $port
return 1
}
# The variable $bespice_listen_port is passed to bespice wave when the application is started
# in the function "set_sim_defaults()".
# if $bespice_listen_port is set to 0 TCL will automatically find a free port
if {[catch {socket -server bespice_server $bespice_listen_port} err]} {
# failed
puts "setup_tcp_bespice: problems finding a free TCP port"
puts $err
return 0
} else {
# succeded => set $bespice_listen_port and socket connection for communication
set chan $err
set bespice_server_getdata(server) $chan
set assigned_port [lindex [chan configure $chan -sockname] end]
set bespice_listen_port $assigned_port
puts stderr "setup_tcp_bespice: success : listening to TCP port: $bespice_listen_port"
return 1
}
puts "setup_tcp_bespice: problems listening to TCP port: $bespice_listen_port ... $last_port"
puts $err
return 0
}
# bespice_listen_port not defined, nothing to do
# puts "setup_tcp_bespice: the functionallity was not set up as the variable \$bespice_listen_port hasn't been defined in your xschemrc file."
# puts "setup_tcp_bespice: the functionallity was not set up as the variable \$bespice_listen_port"
# puts "hasn't been defined in your xschemrc file."
return 1
}