# do not rename this test file to `net.agn`

t := time();
print("Checking net functions\n");
list := ['127.0.0.1', 1234];
readlib 'net';

for i to 1k do
   d := net.open();
   if [net.bind(d)] <> list then
      print('error in net.bind')
   fi;
   if [net.address(d)] <> list then
      print('error in net.address')
   fi;
   if net.lookup('127.0.0.1').networkaddress <> [list[1]] then
      print('error in net.lookup, 1')
   fi;
   if net.lookup('localhost').networkaddress <> [list[1]] then
      print('error in net.lookup, 1')
   fi;
   net.close(d);
   if os.system()[1] = 'Windows' then
      if net.openwinsock() <> true then
         print('error in net.openwinsock')
      fi;
      if net.closewinsock() <> true then
         print('error in net.closewinsock')
      fi;
   fi
od;

print('net: ' & tostring(time() - t));

# delete all global names
clear d, list;
