home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s038 / 1.ddi / SUPP.LIF / CLNT.PLM < prev    next >
Encoding:
Text File  |  1992-07-06  |  6.9 KB  |  155 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 using the iRMX II/III    **
  13.  **       Operating Systems.                                          **
  14.  **                                                                   **
  15.  **                                                                   **
  16.  **    USAGE:                                                         **
  17.  **                                                                   **
  18.  **    This program can be executed on any MULTIBUS-II board          **
  19.  **    running the iRMX II/III Operating Systems.                     **
  20.  **    The board must be situated in slot CLIENT$PSB$SLOT, where      **
  21.  **    CLIENT$PSB$SLOT and SERVER$PSB$SLOT are defined in utils.lit.  **
  22.  **                                                                   **
  23.  **                                                                   **
  24.  **    ALGORITHM:                                                     **
  25.  **                                                                   **
  26.  **    1. Enable in-line exception handling feature.                  **
  27.  **                                                                   **
  28.  **    2. Create a port object and associate it with a default        **
  29.  **       remote socket.                                              **
  30.  **                                                                   **
  31.  **    3. Prompt the user for a string of characters (the message).   **
  32.  **                                                                   **
  33.  **    4. Encrypt the message (the message will be placed in the      **
  34.  **       control section of the packet to be sent to board in slot   **
  35.  **       SERVER$PSB$SLOT).                                           **
  36.  **                                                                   **
  37.  **    5. Send the encrypted message to the board in slot             **
  38.  **       SERVER$PSB$SLOT.  (The message is sent asynchronously)      **
  39.  **                                                                   **
  40.  **    6. Wait to receive the decrypted message back from board in    **
  41.  **       slot SERVER$PSB$SLOT.                                       **
  42.  **                                                                   **
  43.  **    7. Display  the message received to the console.               **
  44.  **                                                                   **
  45.  **    8. Repeat steps 3 - 8.                                         **
  46.  **                                                                   **
  47.  **                                                                   **
  48.  ***********************************************************************/
  49.  
  50. client: DO;
  51.  
  52. $INCLUDE (utils.lit)
  53. $INCLUDE (utils.ext)
  54.  
  55. $INCLUDE (:RMX:inc/nuclus.ext)
  56. $INCLUDE (:RMX:inc/bios.ext)
  57. $INCLUDE (:RMX:inc/eios.ext)
  58. $INCLUDE (:RMX:inc/hi.ext)
  59. $INCLUDE (:RMX:inc/udi.ext)
  60.  
  61.     DECLARE    inbuffptr                POINTER,
  62.             msg$info$struc            MSG_INFO_STRUCT,
  63.             port$info$struc            PORT_INFO_STRUCT,
  64.             port$tkn                TOKEN,
  65.             server$socket            DWORD,
  66.             socket                    DWORD,
  67.             status                    WORD,
  68.             trans$id                WORD,
  69.             eh_handler                EX_HANDLER_STRUCT,
  70.             control$msg$buff (20)    BYTE,
  71.             count                    BYTE,
  72.             index                    BYTE,
  73.             server$socket$ovl        STRUCTURE    (psb$slot    WORD,
  74.                                                  port$id    WORD)
  75.                                     AT    (@server$socket),
  76.  
  77.         message  (*)    BYTE DATA (32,'Enter any string of characters: '),
  78.         message2 (*)    BYTE DATA (21,'Message received is: '),
  79.         message3 (*)    BYTE DATA (2,CR,LF,0);
  80.  
  81.  
  82. /**********************************************************************
  83.  ************************ MAIN PROGRAM BEGINS *************************
  84.  **********************************************************************/
  85. main:
  86.  
  87.     /*    Enable in-line exception handling    */
  88.     CALL rq$get$exception$handler(@eh_handler,@status);
  89.     eh_handler.mode = 0;
  90.     CALL rq$set$exception$handler(@eh_handler,@status);
  91.  
  92.     /*    Create the port object for this board    */
  93.     port$info$struc.portid        = CLIENT$PORT$ID;    /*    This Board            */
  94.     port$info$struc.type        = DATA$SERVICE;        /*    Transport Protocol    */
  95.     port$info$struc.flags        = FIFO$PORT$QUEUEING;
  96.     port$info$struc.reserved    = 0;
  97.     port$tkn = rq$create$port (2, @port$info$struc,@status);   
  98.     CALL check$exception (@(14,'rq$create$port'), status);
  99.  
  100.     /*    Set up the socket for the Server    */
  101.     server$socket$ovl.psb$slot    = SERVER$PSB$SLOT;    /*    Server PSB slot    */
  102.     server$socket$ovl.port$id    = SERVER$PORT$ID;    /*    Server Port ID    */
  103.  
  104.     /*    Create a default socket to get to the board in slot SERVER$PSB$SLOT. */
  105.     CALL rq$connect (port$tkn,server$socket,@status);  
  106.     CALL check$exception (@(10,'rq$connect'), status); 
  107.  
  108.     DO count = 0 TO 5;
  109.  
  110.         CALL rq$c$send$co$response (@control$msg$buff,19,@message,@status);
  111.         CALL check$exception (@(21,'rq$c$send$co$response'), status);
  112.  
  113.         /*    Encrypt the message before sending it    */
  114.         index = 1;    /*    Skip the count byte    */
  115.         DO WHILE ((control$msg$buff(index) <> CR) AND (index < 20));
  116.             control$msg$buff (index) = encrypt (control$msg$buff(index));
  117.             index = index + 1;
  118.         END;
  119.  
  120.  
  121.         /*    Send the mesage to the Server.
  122.          *    The control portion of the message will hold the message.
  123.          */
  124.         trans$id = rq$send (port$tkn,server$socket,@control$msg$buff,
  125.                              NIL,0,0,@status); 
  126.         CALL check$exception (@(7,'rq$send'),status);
  127.  
  128.         /*    Receive the converted message from the Server.    */
  129.         inbuffptr = rq$receive (port$tkn,WAIT$FOREVER,@msg$info$struc,@status);
  130.         CALL check$exception (@(10,'rq$receive'),status);
  131.  
  132.         /*    Display the received message    */
  133.         CALL rq$c$send$co$response (NIL,0,@message2,@status);
  134.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  135.  
  136.         /*    Message is contained in the control buffer    */
  137.         CALL rq$c$send$co$response (NIL,0,@msg$info$struc.control$msg,@status);
  138.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  139.  
  140.         /*    Force a new line    */
  141.         CALL rq$c$send$co$response (NIL,0,@message3,@status);
  142.         CALL check$exception (@(21,'rq$c$send$co$response'),status);
  143.  
  144.     END;    /*    DO count = 0 TO 5    */
  145.  
  146.     /*    Clean up    */
  147.     CALL rq$delete$port (port$tkn, @status);
  148.     CALL check$exception (@(14,'rq$delete$port'),status);
  149.  
  150.     /*    Exit gracefully    */
  151.     CALL rq$exit$io$job (0,NIL, @status);
  152.     CALL check$exception (@(14,'rq$exit$io$job'),status);
  153.  
  154. END client;    /*    End of module    */
  155.