home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / RXNETB.ZIP / TESTR.CMD < prev    next >
OS/2 REXX Batch file  |  1992-10-03  |  4KB  |  76 lines

  1. /*                                                               */
  2. /*      REXX/NETBIOS Sample Client Pgm                           */
  3. /*                                                               */
  4. /*                                                               */
  5. /*      Tell REXX there is a new function available              */
  6. /*                                                               */
  7.  
  8. call rxfuncadd 'netbios', 'rexxnetb', 'netbiossrv'
  9. /*                                                               */
  10. /*      Client station name, must be 16 bytes                    */
  11. /*                                                               */
  12.  
  13. Myname=left('Sample',16,' ')
  14. RemoteName =left('*',16,' ')
  15.  
  16. /*                                                               */
  17. /*      call netbios and get resources from the global pool      */
  18. /*      defined in PROTOCOL.INI                                  */
  19. /*                                                               */
  20.  
  21. rc=netbios('Reset',0,1,1,1)
  22.  
  23. /*                                                               */
  24. /* if resources available                                        */
  25. /*                                                               */
  26.  
  27. if rc=0 then do
  28.  
  29. /*                                                               */
  30. /* add our name to the network, and get the name number          */
  31. /*                                                               */
  32.  
  33.   parse value netbios('AddName',0,MyName) with rc name_num .
  34.  
  35. /*                                                               */
  36. /* If we are on the network now,                                 */
  37. /* Listen  for a call now                                        */
  38. /*                                                               */
  39.   parse value netbios('Listen',0,MyName,RemoteName,0,0) with rc lsn CallerName .
  40.  
  41. /*                                                               */
  42. /* If Listen succeeded wait for a message                        */
  43. /*                                                               */
  44.   if rc=0 then do
  45.     rc=netbios('Receive',0,lsn,1000,'data.')
  46. /*                                                               */
  47. /* If receive succeeded report the received message              */
  48. /*                                                               */
  49.     if rc=0 then do
  50.       say 'We received the following message from "' || strip(CallerName) || '"'
  51.       say data.0
  52. /*                                                               */
  53. /* and send it back with some additional info                    */
  54. /*                                                               */
  55.       call netbios 'Send',0,lsn,data.0 'Response'
  56.     end
  57. /*                                                               */
  58. /* end session now as we are done                                */
  59. /*                                                               */
  60.     call netbios 'Hangup',0,lsn
  61.   end
  62.  
  63. /*                                                               */
  64. /* return our netbios resources to the global pool               */
  65. /*                                                               */
  66.  
  67. call netbios 'Close',0
  68.  
  69. end
  70.  
  71. /*                                                               */
  72. /* oops, either no Netbios resources are available or            */
  73. /*       Netbios is not installed                                */
  74. /*                                                               */
  75. else say 'Netbios resources not available rc='rc
  76.