home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / RXSOCK.ZIP / test_c4.cmd < prev    next >
OS/2 REXX Batch file  |  1993-07-19  |  2KB  |  115 lines

  1. /*------------------------------------------------------------------
  2.  * test_c.cmd :
  3.  *------------------------------------------------------------------
  4.  * 08-05-92 originally by Patrick J. Mueller
  5.  *------------------------------------------------------------------*/
  6.  
  7. trace off
  8.  
  9. /*------------------------------------------------------------------
  10.  * initialize socket package
  11.  *------------------------------------------------------------------*/
  12. parse source os .
  13.  
  14. if (os = "OS/2") then
  15.    do
  16.    if RxFuncQuery("SockLoadFuncs") then
  17.       do
  18.       rc = RxFuncAdd("SockLoadFuncs","RxSock","SockLoadFuncs")
  19.       rc = SockLoadFuncs()
  20.       end
  21.    end
  22.  
  23. if (os = "AIX/6000") then
  24.    do
  25.    rc = SysAddFuncPkg("rxsock.dll")
  26.    end
  27.  
  28. /*---------------------------------------------------------------
  29.  * open socket
  30.  *---------------------------------------------------------------*/
  31. s.0 = 3
  32. do i = 1 to 3
  33.    s.i  = SockSocket("AF_INET","SOCK_STREAM",0)
  34. end
  35.  
  36. call on halt name doHalt
  37.  
  38. say
  39. say "calling with no timeout (press ctrl-break)"
  40. call doSelect
  41.  
  42. say
  43. say "calling with null timeout (press ctrl-break)"
  44. call doSelect ""
  45.  
  46. say
  47. say "calling with -1 second timeout"
  48. call doSelect -1
  49.  
  50. say
  51. say "calling with X second timeout"
  52. call doSelect "x"
  53.  
  54. say
  55. say "calling with 0 second timeout"
  56. call doSelect 0
  57.  
  58. say
  59. say "calling with 5 second timeout"
  60. call doSelect 5
  61.  
  62. say
  63. say "calling with 2 second timeout, no sockets"
  64. s.0 = 0
  65. call doSelect 2
  66.  
  67. say
  68. say "calling with 1 second timeout, empty parms"
  69. rc = SockSelect(,,,1)
  70. say "rc from SockSelect:" rc
  71.  
  72. exit
  73.  
  74. /*------------------------------------------------------------------
  75.  * ctrl-break handler
  76.  *------------------------------------------------------------------*/
  77. doHalt:
  78.     return
  79.  
  80. /*------------------------------------------------------------------
  81.  * call select
  82.  *------------------------------------------------------------------*/
  83. doSelect: procedure expose s.
  84.  
  85.    r.0 = s.0
  86.    w.0 = s.0
  87.    e.0 = s.0
  88.  
  89.    do i = 1 to s.0
  90.       r.i = s.i
  91.       w.i = s.i
  92.       e.i = s.i
  93.    end
  94.  
  95.    if (arg() = 1) then
  96.       rc = SockSelect("r.","w.","e.",arg(1))
  97.    else
  98.       rc = SockSelect("r.","w.","e.")
  99.  
  100.    say "rc from SockSelect:" rc
  101.  
  102.    do i = 1 to r.0
  103.       say "   ready for read:  " r.i
  104.    end
  105.  
  106.    do i = 1 to w.0
  107.       say "   ready for write: " w.i
  108.    end
  109.  
  110.    do i = 1 to e.0
  111.       say "   ready for except:" e.i
  112.    end
  113.  
  114.    return
  115.