home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s038 / 1.ddi / SUPP.LIF / MCFSRVR.PLM < prev    next >
Encoding:
Text File  |  1992-07-06  |  8.9 KB  |  204 lines

  1. $compact optimize(3) debug pw(79) rom
  2.  
  3.  
  4. /***********************************************************************
  5.  **                                                                   **
  6.  **                                                                   **
  7.  **    OBJECTIVES:                                                    **
  8.  **                                                                   **
  9.  **    1. To demonstrate the concepts behind synchronous vs.          **
  10.  **       asynchronous MULTIBUS-II system calls.                      **
  11.  **                                                                   **
  12.  **    2. To better acquaint the user with the idea of sending        **
  13.  **       and receiving solicited messages using the iRMX II/III      **
  14.  **       Operating Systems.                                          **
  15.  **                                                                   **
  16.  **    3. To demonstrate buffer pool usage.                           **
  17.  **                                                                   **
  18.  **                                                                   **
  19.  **    USAGE:                                                         **
  20.  **                                                                   **
  21.  **    This program can be executed on any MULTIBUS-II board          **
  22.  **    running the iRMX II/III Operating System.                      **
  23.  **    The board must be situated in slot SERVER$PSB$SLOT, where      **
  24.  **    CLIENT$PSB$SLOT and SERVER$PSB$SLOT are defined in utils.lit.  **
  25.  **                                                                   **
  26.  **                                                                   **
  27.  **    ALGORITHM:                                                     **
  28.  **                                                                   **
  29.  **    1. Enable in-line exception handling feature.                  **
  30.  **                                                                   **
  31.  **    2. Create a port object and associate it with a default        **
  32.  **       remote socket.                                              **
  33.  **                                                                   **
  34.  **    3. Create a buffer pool object and associate it with the       **
  35.  **       port created in step 2.                                     **
  36.  **                                                                   **
  37.  **    4. Create a number of buffers and release buffers to the       **
  38.  **       buffer pool above.                                          **
  39.  **                                                                   **
  40.  **    5. Receive an ENCRYPTED message from board in slot             **
  41.  **       CLIENT$PSB$SLOT.                                            **
  42.  **                                                                   **
  43.  **    6. Move the message received from the buffer pool buffer       **
  44.  **       to the application buffer.                                  **
  45.  **                                                                   **
  46.  **    7. Release the buffer used by the Nucleus (the buffer used     **
  47.  **       by the iRMX II Nucleus during message passing) back to      **
  48.  **       the buffer pool.                                            **
  49.  **                                                                   **
  50.  **    8. Decrypt the message received and display it at the console. **
  51.  **                                                                   **
  52.  **    9. Send the DECRYPTED message back to the board in slot        **
  53.  **       CLIENT$PSB$SLOT.                                            **
  54.  **                                                                   **
  55.  **    10. Repeat steps 5 - 10.                                       **
  56.  **                                                                   **
  57.  **                                                                   **
  58.  ***********************************************************************/
  59.  
  60. server: DO;
  61.  
  62.  
  63. $INCLUDE (utils.lit)
  64. $INCLUDE (utils.ext)
  65.  
  66. $INCLUDE (:RMX:inc/nuclus.ext)
  67. $INCLUDE (:RMX:inc/bios.ext)
  68. $INCLUDE (:RMX:inc/eios.ext)
  69. $INCLUDE (:RMX:inc/hi.ext)
  70. $INCLUDE (:RMX:inc/udi.ext)
  71.  
  72. DECLARE    buffer$tkn            TOKEN,
  73.         bufpool$tkn            TOKEN,
  74.         inbuffptr            POINTER,
  75.         index                WORD,
  76.         eh_handler            EX_HANDLER_STRUCT,
  77.         msg$info$struc        MSG_INFO_STRUCT,
  78.         port$info$struc        PORT_INFO_STRUCT,
  79.         port$tkn            TOKEN,
  80.         server$socket        DWORD,
  81.         server$socket$ovl    STRUCTURE    (psb$slot    WORD,
  82.                                          port$id    WORD)
  83.                             AT    (@server$socket),
  84.         socket                DWORD,
  85.         status                WORD,
  86.         trans$id            WORD;
  87.  
  88. DECLARE    count                BYTE,
  89.         data$buff(255)        BYTE,
  90.         message  (*)        BYTE    DATA (21,'Message received is: '),
  91.         message2 (*)        BYTE    DATA (22,'Converted message is: '),
  92.         message3 (*)        BYTE    DATA (2,CR,LF,0);
  93.  
  94.  
  95.  
  96. /**********************************************************************
  97.  ************************ MAIN PROGRAM BEGINS *************************
  98.  **********************************************************************/
  99. main:
  100.  
  101.     /*    Set up the socket for the Client    */
  102.     server$socket$ovl.psb$slot    = CLIENT$PSB$SLOT;    /*    Client PSB slot    */
  103.     server$socket$ovl.port$id    = CLIENT$PORT$ID;    /*    Client Port ID    */
  104.  
  105.     /*    Enable in-line exception handling    */
  106.     CALL rq$get$exception$handler (@eh_handler,@status);
  107.     eh_handler.mode = 0;
  108.     CALL rq$set$exception$handler (@eh_handler,@status);
  109.  
  110.     /*    Create the port object for this board    */
  111.     port$info$struc.portid        = SERVER$PORT$ID;    /*    This Board            */
  112.     port$info$struc.type        = DATA$SERVICE;        /*    Transport Protocol    */
  113.     port$info$struc.flags        = FIFO$PORT$QUEUEING;
  114.     port$info$struc.reserved    = 0;
  115.     port$tkn = rqcreate$port (2, @port$info$struc,@status);   
  116.     CALL check$exception (@(14,'rq$create$port'),status);
  117.  
  118.     /*    Associate destination socket to port    */
  119.     CALL rq$connect (port$tkn,server$socket,@status); 
  120.     CALL check$exception (@(10,'rq$connect'),status);
  121.  
  122.     /*    Create a buffer pool object    */
  123.     bufpool$tkn = rq$create$buffer$pool (30,0,@status);
  124.     CALL check$exception (@(21,'rq$create$buffer$pool'),status);
  125.  
  126.     /*    Attach the buffer pool to a default socket    */
  127.     CALL rq$attach$buffer$pool (bufpool$tkn,port$tkn,@status);
  128.     CALL check$exception (@(21,'rq$attach$buffer$pool'),status);
  129.  
  130.     /*    Create and release buffers to the buffer pool    */
  131.     DO count = 0 TO 5;
  132.  
  133.         /*    Create a buffer    */
  134.         buffer$tkn = rq$create$segment (1024,@status);
  135.         CALL check$exception (@(17,'rq$create$segment'),status);
  136.  
  137.         /*    Release the buffer to the buffer pool    */
  138.         CALL rq$release$buffer (bufpool$tkn,buffer$tkn,0,@status);
  139.         CALL check$exception (@(17,'rq$release$buffer'),status);
  140.  
  141.     END;    /*    DO count = 0 TO 5    */
  142.  
  143.  
  144.     DO count = 0 TO 7;
  145.  
  146.         /*    Get the message from the Client    */
  147.         inbuffptr = rq$receive (port$tkn,WAIT$FOREVER,@msg$info$struc,@status);
  148.         CALL check$exception (@(10,'rq$receive'),status);
  149.  
  150.         /*    Move buffer contents into program buffer.    */
  151.         CALL MOVB (inbuffptr,@data$buff,BYTE(msg$info$struc.data$length));
  152.  
  153.         /*    Find buffer token of buffer used for the rq$receive system call    */
  154.         buffer$tkn = SELECTOR$OF(inbuffptr);
  155.  
  156.         /*    Release the buffer back to the buffer pool    */
  157.         CALL rq$release$buffer (buf$pool$tkn,buffer$tkn,0,@status);
  158.         CALL check$exception (@(17,'rq$release$buffer'),status);
  159.  
  160.         /*    Display the original (encrypted) message received. */
  161.         CALL rq$c$send$co$response (NIL,0,@message,@status);
  162.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  163.  
  164.         /*    The iRMX string form of the message is now in data$buff    */
  165.         CALL rq$c$send$co$response(NIL,0,@data$buff,@status); 
  166.         CALL check$exception( @(21,'rq$c$send$co$response'), status);
  167.  
  168.         /*    Translate (decrypt) the message received    */
  169.         index = 1;    /*    Skip the count byte    */
  170.         DO WHILE ((data$buff(index) <> CR) AND (index < 255));
  171.             data$buff(index) = decrypt (data$buff(index));
  172.             index = index + 1;
  173.         END;
  174.  
  175.  
  176.         /*    Display the decrypted message to the console    */
  177.         CALL rq$c$send$co$response (NIL,0,@message2,@status);
  178.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  179.  
  180.         /*    The iRMX string form of the message is now in data$buff    */
  181.         CALL rq$c$send$co$response (NIL,0,@data$buff,@status);
  182.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  183.  
  184.         /*    Force a new line    */
  185.         CALL rq$c$send$co$response (NIL,0,@message3,@status);
  186.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  187.  
  188.         /*    Return (send) the translated message back to the sender    */
  189.         trans$id = rq$send (port$tkn,server$socket,@msg$info$struc.control$msg,
  190.             @data$buff,DWORD(data$buff(0))+1,0,@status);
  191.         CALL check$exception (@(7,'rq$send'),status);
  192.  
  193.     END;    /*    DO count = 0 TO 7    */
  194.  
  195.     /*    clean up    */
  196.     CALL rq$delete$port (port$tkn,@status);
  197.     CALL check$exception (@(14,'rq$delete$port'),status);
  198.  
  199.     /*    Exit gracefully    */
  200.     CALL rq$exit$io$job (0,NIL,@status);
  201.     CALL check$exception (@(14,'rq$exit$io$job'),status);
  202.  
  203. END server;    /*    End of module    */
  204.