A% dp_address info $a128.84.154.8 0 {alvin.cs.cornell.edu fw.cs.cornell.edu alvin.cs alvinfw.cs fw}The return value shows that the IP address offw.cs.cornell.edu is128.84.154.8, andthat it is known by a variety of names, including alvin, alvin.cs, andfw.cs.cornell.edu. The dp_address command can be used to create a function thatreturns the IP address given a host’s name, or vice versa, as shown in the two functions below.A% proc InetAddress {hostname} {set addr [dp_address create $hostname 0]set x [dp_address info $addr]dp_address delete $addrlindex $x 0}A% proc Hostname {inetAddr} {set addr [dp_address create $inetAddr 0]dp_address delete $addrlindex [lindex $x 2] 0}A% InetAddress alvin.cs.cornell.edu128.84.154.8A% Hostname 128.84.154.8alvin.cs.cornell.eduBy the way, as shown in the next to last line of each of the procedures above, you should executethedp_addressdelete command to free up the memory associated with an address when youare finished with it.Learning MoreThat concludes our tour of the Tcl-DP extension to Tcl/Tk. There are a few other features in Tcl-DP that we haven’t discussed, but we have covered the main ones here. We hope you have gainedan appreciation for how simple it is to build distributed programs using Tcl-DP and that you haveenough background now to explore on your own. To learn more, study the examples in theexamples subdirectory, post articles to thecomp.lang.tcl newsgroup, and read the manualpages in thedoc ...
Voir