home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / RXAPPC.ZIP / TP2.CMD < prev   
OS/2 REXX Batch file  |  1992-10-03  |  3KB  |  62 lines

  1. /*                                                                 */
  2. /* REXX/APPC transaction program sample  (server)                  */
  3. /*                                                                 */
  4. trace off
  5. /*                                                                 */
  6. /* Tell Rexx that there is a new function available                */
  7. /*                                                                 */
  8.  
  9. CALL RXFUNCADD APPC,SAAAPPC,APPCSRV
  10.  
  11. /*                                                                 */
  12. /* Tell APPC that we are TP2 and we're ready to talk to any other  */
  13. /* TP that calls us.                                               */
  14. /*                                                                 */
  15.  
  16. rc=appc('Receive_allocate','TP2','Lu2s.')
  17.  
  18. tpid=lu2s.0                     /* save the TP ID                  */
  19. convid=lu2s.1                   /* and conversation ID             */
  20. ConvType=Lu2s.3            /* get Conversation type (Basic/Mapped) */
  21.  
  22. /*                                                                 */
  23. /* Lets receive some data from our partner.                        */
  24. /*                                                                 */
  25. /* Note: This is a 'Mapped' Conversation.                          */
  26. /*                                                                 */
  27.  
  28. rc=appc('Receive_wait',tpid,convid,ConvType,'data.',1000)
  29. say data.2
  30.  
  31. /*                                                                 */
  32. /* We have the data. In this sample, we know there is no more      */
  33. /* data coming, so a receive_immediate will turn the line around.  */
  34. /* In reality one should check the state after the receive_wait    */
  35. /* to see if all the data was received, and check again after      */
  36. /* the receive_immediate.                                          */
  37. /*                                                                 */
  38. /* But were skimping here, cause its only a sample                 */
  39. /*                                                                 */
  40.  
  41. rc=appc('Receive_immediate',tpid,convid,ConvType,'data1.',1000)
  42.  
  43. /*                                                                 */
  44. /*  We should be in 'SEND' state now, that means WE can SEND       */
  45. /*  data1.0 should contain 'SEND' as what_received                 */
  46. /*                                                                 */
  47.  
  48. rc=appc('Send_data',tpid,convid,ConvType,'Hello from tp2')
  49.  
  50. /*                                                                 */
  51. /*  OK, data sent. Now we are done.                                */
  52. /*  Tell APPC that this transaction is complete.                   */
  53. /*                                                                 */
  54. /*  This could be a 'do forever' loop processing single            */
  55. /*  transmissions from multiple requestors one at a time.          */
  56. /*                                                                 */
  57. /*                                                                 */
  58.  
  59. rc=appc('Tp_ended',tpid)
  60.  
  61. 'exit'
  62.