I use a script that lists all the ports used by Cloverleaf. I often will pipe the output to grep, sort, etc. depending on what I need. Then I select the next number available for my new tcp/ip thread.
#!/qdx/qdx5.7/integrator/bin/tcl
set hciRoot /qdx/qdx5.7/integrator
# List of sites to exclude from the search
set siteExclusions {}
# Get site names from the server.ini
set sites [exec grep environs $hciRoot/server/server.ini]
regsub {environs=} $sites {} sites
set sites [lsort [split $sites ;]]
foreach site $sites {
set site [file tail $site]
if {[lsearch -exact $siteExclusions $site] == -1} {
eval [exec $hciRoot/sbin/hcisetenv -root tcl $hciRoot $site]
netcfgLoad $hciRoot/$site/NetConfig
set connList [lsort [netcfgGetConnList]]
foreach conn $connList {
set protocol “”
set host “”
set port “”
set pdlType “”
set data [netcfgGetConnData $conn]
keylget data PROTOCOL.TYPE protocol
keylget data PROTOCOL.HOST host
keylget data PROTOCOL.PORT port
keylget data PROTOCOL.PDLTYPE pdlType
# Get the name of the process
set klst [netcfgGetConnData $conn]
set process [keylget klst PROCESSNAME]
# Get the “Summary:” line from the notes and output the results
set note “”
set notesFile “$hciRoot/$site/notes/NetConfig/$process/thread_$conn.notes”
if {[file exists $notesFile]} {
catch {exec /bin/grep Summary: $notesFile} note
# Ignore this warning from grep
if {$note == “child process exited abnormally”} {set note “”}
# Remove the “Summary:” text
regsub — {^Summary: ?} $note {} note
}
# Slightly different output for tcp/ip clients and servers
if {$protocol == “pdl-tcpip”} {
set protocol $pdlType
}
# Don’t output notes if there is no Summary: line in the notes
if {$note == “”} {
puts $site:$conn:$protocol:$host:$port
} else {
puts $site:$conn:$protocol:$host:$port:$note
}
}
}
}
# End of Script