Aug 23, 2002 #1 bvdang Programmer Joined Aug 15, 2002 Messages 4 Location US Does anybody know how I can obtain a local ip address using tcl command? I need to get the ip address in order to connect to MySQL database. Thanks,
Does anybody know how I can obtain a local ip address using tcl command? I need to get the ip address in order to connect to MySQL database. Thanks,
Aug 23, 2002 #2 ulis Programmer Joined Oct 12, 2001 Messages 429 Location FR I tried this trick and it works: Code: set port 3456 set my_name nt2000fr socket -server ip_add $port proc ip_add {channel ip port} { puts $ip } close [socket $my_name $port] Setting my_name to 'localhost' prints 127.0.0.1. Can't you use 'localhost' or '127.0.0.1' as local IP address? Good luck ulis Upvote 0 Downvote
I tried this trick and it works: Code: set port 3456 set my_name nt2000fr socket -server ip_add $port proc ip_add {channel ip port} { puts $ip } close [socket $my_name $port] Setting my_name to 'localhost' prints 127.0.0.1. Can't you use 'localhost' or '127.0.0.1' as local IP address? Good luck ulis
Aug 23, 2002 #3 ulis Programmer Joined Oct 12, 2001 Messages 429 Location FR A better solution to get a local IP address (don't need to choose a port # or give the host name): Code: proc ip:adr {} { set me [socket -server xxx -myaddr [info hostname] 0] set ip [lindex [fconfigure $me -sockname] 0] close $me return $ip } This come from http://mini.net/tcl/3015 ulis Upvote 0 Downvote
A better solution to get a local IP address (don't need to choose a port # or give the host name): Code: proc ip:adr {} { set me [socket -server xxx -myaddr [info hostname] 0] set ip [lindex [fconfigure $me -sockname] 0] close $me return $ip } This come from http://mini.net/tcl/3015 ulis