home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Online / RxSocket / Examples / suitable.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2001-05-24  |  823 b   |  37 lines

  1. /*
  2.     Searches for a "suitable interface"
  3.     wich means "up and not loopback"
  4. */
  5.  
  6. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  7. call MacroEnv("env","stderr")
  8. if AddLibrary("rexxsupport.library","rxsocket.library","rxlibnet.library")~=0 then
  9.     call err "Can't find" result,1
  10.  
  11. if arg()~=0 then do
  12.     if arg()=1 & arg(1)="?" then do
  13.         say env.prg": searches for a suitable interface"
  14.     end
  15.     else call PrintFault(118)
  16.     exit
  17. end
  18.  
  19. res=QueryInterfaces("in")
  20. if res<0 then do
  21.     say env.prg": cannot query ("errorstring()")"
  22.     exit
  23. end
  24. if res=0 then do
  25.     say env.prg": no suitable device found"
  26.     exit
  27. end
  28.  
  29. do i=0 to res-1
  30.     if in.i.family==2 & in.i.UP==1 & in.i.LOOPBACK==0 then do
  31.         say env.prg":" in.i.NAME
  32.         exit
  33.     end
  34. end
  35.  
  36. say env.prg": no suitable device found"
  37.