If you run the ifconfig command-line tool, you get output like this:
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:0d:93:48:d8:f2
media: autoselect (none) status: inactive
supported media: none autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 100baseTX <half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 1000baseT <full-duplex> 1000baseT <full-duplex,hw-loopback> 1000baseT <full-duplex,flow-control> 1000baseT <full-duplex,flow-control,hw-loopback>
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet6 fe80::211:24ff:fe27:385f%en1 prefixlen 64 scopeid 0x5
inet 192.168.1.67 netmask 0xffffff00 broadcast 192.168.1.255
ether 00:11:24:27:38:5f
media: autoselect status: active
supported media: autoselect
In my case, note that my en0 is not connected, and my en1 is. Correspondingly, there is either 'status:active' or 'status: inactive'. You could run ifconfig, parse the output, and see if there are any active interfaces. Apart from loopback.
There are probably more API-ish ways to do this, but i can't tell you what they are!