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

  1. $compact optimize(3) debug pw(79) rom
  2.  
  3. /***********************************************************************
  4.  **                                                                   **
  5.  **                                                                   **
  6.  **    OBJECTIVES:                                                    **
  7.  **                                                                   **
  8.  **    1. To demonstrate the concepts behind synchronous vs.          **
  9.  **       asynchronous MULTIBUS-II system calls.                      **
  10.  **                                                                   **
  11.  **    2. To better acquaint the user with the idea of sending        **
  12.  **       and receiving unsolicited messages (messages whose data     **
  13.  **       field is set to NULL) using the iRMX II/III Operating       **
  14.  **       Systems.                                                    **
  15.  **                                                                   **
  16.  **                                                                   **
  17.  **                                                                   **
  18.  **    USAGE:                                                         **
  19.  **                                                                   **
  20.  **    This program can be executed on any MULTIBUS-II board          **
  21.  **    running the iRMX II/III Operating Systems.                     **
  22.  **    The board must be situated in slot SERVER$PSB$SLOT, where      **
  23.  **    CLIENT$PSB$SLOT and SERVER$PSB$SLOT are defined in utils.lit.  **
  24.  **                                                                   **
  25.  **                                                                   **
  26.  **    ALGORITHM:                                                     **
  27.  **                                                                   **
  28.  **    1. Enable in-line exception handling feature.                  **
  29.  **                                                                   **
  30.  **    2. Create a port object and associate it with a default        **
  31.  **       remote socket.                                              **
  32.  **                                                                   **
  33.  **    3. Receive an encrypted message from the board in slot         **
  34.  **       CLIENT$PSB$SLOT.                                            **
  35.  **                                                                   **
  36.  **    4. Display the message received in the encrypted form.         **
  37.  **                                                                   **
  38.  **    5. Decrypt the message received and display it at the console. **
  39.  **                                                                   **
  40.  **    6. Send the decrypted message back to the board in slot        **
  41.  **       CLIENT$PSB$SLOT.                                            **
  42.  **                                                                   **
  43.  **    7. Repeat steps 3 - 7.                                         **
  44.  **                                                                   **
  45.  **                                                                   **
  46.  ***********************************************************************/
  47.  
  48. server: DO;
  49.  
  50. $INCLUDE (utils.lit)
  51. $INCLUDE (utils.ext)
  52.  
  53. $INCLUDE (:RMX:inc/nuclus.ext)
  54. $INCLUDE (:RMX:inc/bios.ext)
  55. $INCLUDE (:RMX:inc/eios.ext)
  56. $INCLUDE (:RMX:inc/hi.ext)
  57. $INCLUDE (:RMX:inc/udi.ext)
  58.  
  59.     DECLARE    buffer                TOKEN,
  60.             eh_handler            EX_HANDLER_STRUCT,
  61.             inbuffptr            POINTER,
  62.             index                WORD,
  63.             msg$info$buff        MSG_INFO_STRUCT,
  64.             port$tkn            TOKEN,
  65.             port$info$struc        PORT_INFO_STRUCT,
  66.             server$socket        DWORD,
  67.             socket                DWORD,
  68.             status                WORD,
  69.             trans$id            WORD,
  70.             control$ptr(16)        BYTE,
  71.             count                BYTE,
  72.             server$socket$ovl    STRUCTURE    (psb$slot    WORD,
  73.                                              port$id    WORD)
  74.                                 AT    (@server$socket),
  75.             message  (*)        BYTE    DATA    (20,'MESSAGE RECEIVE IS: '),
  76.             message2 (*)        BYTE    DATA    (19,'CONVERTED MESSAGE: '),
  77.             message3 (*)        BYTE    DATA    (2,CR,LF,0);
  78.  
  79.  
  80. /**********************************************************************
  81.  ************************ MAIN PROGRAM BEGINS *************************
  82.  **********************************************************************/
  83. main:
  84.  
  85.     /*    Set up the socket for the Client    */
  86.     server$socket$ovl.psb$slot    = CLIENT$PSB$SLOT;    /*    Client PSB slot    */
  87.     server$socket$ovl.port$id    = CLIENT$PORT$ID;    /*    Client Port ID    */
  88.    
  89.     /*    Enable in-line exception handling    */
  90.     CALL rq$get$exception$handler (@eh_handler,@status);
  91.     eh_handler.mode = 0;
  92.     CALL rq$set$exception$handler (@eh_handler,@status);
  93.  
  94.     /*    Create the port object for this board    */
  95.     port$info$struc.portid        = SERVER$PORT$ID;    /*    This Board            */
  96.     port$info$struc.type        = DATA$SERVICE;        /*    Transport Protocol    */
  97.     port$info$struc.flags        = FIFO$PORT$QUEUEING;
  98.     port$info$struc.reserved    = 0;
  99.     port$tkn = rqcreate$port (2, @port$info$struc,@status);   
  100.     CALL check$exception (@(14,'rq$create$port'),status);
  101.  
  102.     /*    Associate destination socket to port    */
  103.     CALL rq$connect (port$tkn,server$socket,@status); 
  104.     CALL check$exception (@(10,'rq$connect'),status);
  105.  
  106.     DO count = 0 TO 5;
  107.  
  108.         /*    Get the message from the Client    */
  109.         inbuffptr = rq$receive (port$tkn,WAIT$FOREVER,@msg$info$buff,@status); 
  110.         CALL check$exception (@(10,'rq$receive'),status);
  111.  
  112.         /*    Display message received in original form    */
  113.         CALL rq$c$send$co$response (nil,0,@message,@status);
  114.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  115.  
  116.         /*    Message is contained in the control field    */
  117.         CALL rq$c$send$co$response (nil,0,@msg$info$buff.controlmsg,@status); 
  118.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  119.  
  120.         /*    Translate (decrypt) the message received    */
  121.         index = 1;    /*    Skip the count byte    */
  122.         DO WHILE ((msg$info$buff.controlmsg(index) <> CR) AND (index < 20));
  123.             msg$info$buff.controlmsg(index) =
  124.                 decrypt (msg$info$buff.controlmsg(index));
  125.             index = index + 1;
  126.         END;
  127.  
  128.         /*    Display decrypted message    */
  129.         CALL rq$c$send$co$response (nil,0,@message2,@status);
  130.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  131.  
  132.         /*    Message is in control buffer    */
  133.         CALL rq$c$send$co$response (nil,0,@msg$info$buff.controlmsg,@status);
  134.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  135.  
  136.         /*    Force a new line    */
  137.         CALL rq$c$send$co$response (nil,0,@message3,@status);
  138.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  139.  
  140.  
  141.         /*    Return (send) the decrypted message back to the sender    */
  142.         trans$id = rq$send (port$tkn,server$socket,@msg$info$buff.controlmsg,
  143.                             nil,0,0,@status);
  144.         CALL check$exception (@(7,'rq$send'),status);
  145.  
  146.     END;    /*    DO count = 0 TO 5    */
  147.  
  148.     /*    Clean up    */
  149.     CALL rq$delete$port (port$tkn,@status);
  150.     CALL check$exception (@(14,'rq$delete$port'),status);
  151.  
  152.     /*    Exit gracefully    */
  153.     CALL rq$exit$io$job (0,NIL,@status);
  154.     CALL check$exception (@(14,'rq$exit$io$job'),status);
  155.  
  156. END server;    /*    End of module    */
  157.