Netinfo - Protocol, service, network and host info Directions to find it at [Stu] Netinfo version 0.4, September 2007. * Added "networks" db * A bit of cleanup/adjustment * Documentation improvements ---- ''Netinfo is also the name of a OS subsystem handling these issues in NEXTSTEP and [MacOS X]. What relation, if any, is there between that and [Stu]'s package?'' ---- [Stu] sez: ''No relationship. I was unaware of the NEXTSTEP and [MacOS X] subsystem until now. Netinfo was originally called Netutil but it turned out to be more info-ish than util-ish. Do you think this will cause any problems? Netinfo 0.3 was released a year ago and I haven't had any complains although I have no idea if anyone is using it.'' ---- One example of usage would be to look up hostnames (usually taken from /etc/hosts) using Netinfo and creating sockets (aka ceps) using [Ceptcl] and the -noresolve option. This way, one can avoid the potential delays caused by the operating system looking up the hostname. From the man page: The netinfo Tcl extension provides access to system proto- col, service, network and host information which is retrieved from system databases and made available for querying. This functionality is somewhat analogous to that provided by some of the functions referenced in the C include file usually found on unix-like oper- ating systems (gethostbyname, getservbyport, etc). Unlike those functions, netinfo does not go beyond referencing the data stored in the system "databases"; netinfo does not access the databases per query, rather it loads the data and parses it into an internal ready-for-querying format. If any changes are made to the databases after loading then the affected databases would need to be reloaded if the changes are to be available to netinfo queries. Normal usage involves optionally specifying any database files if the defaults do not match your reality, calling as many of the "load" commands as are necessary (depending on what data you need to access; netinfo does not load anything at startup) and using the querying and extraction commands to retrieve info. Examples: # Results noted with #=> package require netinfo namespace import ::netinfo::* loadProtocolData; loadServiceData; loadNetworkData; loadHostData protocolData [protocol -number 123] -comment #=> Performance Transparency Protocol protocolData [protocol -number 123] -comment -name #=> {Performance Transparency Protocol} ptp service -port 9 #=> discard 9 {sink null} {} tcp service -port 9 -protocol udp #=> discard 9 {sink null} {} udp service -port 9 -protocol * #=> {discard 9 {sink null} {} tcp} {discard 9 {sink null} {} udp} serviceData [lindex [service -port 9 -protocol *] 1] -protocol -port #=> udp 9 network -number 127 #=> loopback loop {} 127 networkData [network -number 224] -name #=> BASE-ADDRESS.MCAST.NET hostData [host -aliases localhost] -address #=> 127.0.0.1 hostData [host -aliases localhost -domain inet6] -address #=> ::1 # List all services: service -name * ---- [[ [Category Package] | [Category Internet] ]]