Test to see if TCP/IP is active

Would something like this work?


set activeTCP to {}
tell application "Network Setup Scripting" 
try 
open database 
set activeTCP to name of item 1 of every TCPIP v4 configuration whose active is true 
close database 
on error 
close database 
end try 
end tell
if activeTCP is {} then display dialog "There is no active TCP/IP configuration."