im trying to make a sniplet for somtehing like

if ($network isconnected ) { halt }

i want it to stop trying to connect to the server if its already connected
any ideas?