home *** CD-ROM | disk | FTP | other *** search
- $compact optimize(3) debug pw(79) rom
-
-
- /***********************************************************************
- ** **
- ** **
- ** OBJECTIVES: **
- ** **
- ** 1. To demonstrate the concepts behind synchronous vs. **
- ** asynchronous MULTIBUS-II system calls. **
- ** **
- ** 2. To better acquaint the user with the idea of sending **
- ** and receiving solicited messages using the iRMX II/III **
- ** Operating Systems. **
- ** **
- ** 3. To demonstrate buffer pool usage. **
- ** **
- ** **
- ** USAGE: **
- ** **
- ** This program can be executed on any MULTIBUS-II board **
- ** running the iRMX II/III Operating System. **
- ** The board must be situated in slot SERVER$PSB$SLOT, where **
- ** CLIENT$PSB$SLOT and SERVER$PSB$SLOT are defined in utils.lit. **
- ** **
- ** **
- ** ALGORITHM: **
- ** **
- ** 1. Enable in-line exception handling feature. **
- ** **
- ** 2. Create a port object and associate it with a default **
- ** remote socket. **
- ** **
- ** 3. Create a buffer pool object and associate it with the **
- ** port created in step 2. **
- ** **
- ** 4. Create a number of buffers and release buffers to the **
- ** buffer pool above. **
- ** **
- ** 5. Receive an ENCRYPTED message from board in slot **
- ** CLIENT$PSB$SLOT. **
- ** **
- ** 6. Move the message received from the buffer pool buffer **
- ** to the application buffer. **
- ** **
- ** 7. Release the buffer used by the Nucleus (the buffer used **
- ** by the iRMX II Nucleus during message passing) back to **
- ** the buffer pool. **
- ** **
- ** 8. Decrypt the message received and display it at the console. **
- ** **
- ** 9. Send the DECRYPTED message back to the board in slot **
- ** CLIENT$PSB$SLOT. **
- ** **
- ** 10. Repeat steps 5 - 10. **
- ** **
- ** **
- ***********************************************************************/
-
- server: DO;
-
-
- $INCLUDE (utils.lit)
- $INCLUDE (utils.ext)
-
- $INCLUDE (:RMX:inc/nuclus.ext)
- $INCLUDE (:RMX:inc/bios.ext)
- $INCLUDE (:RMX:inc/eios.ext)
- $INCLUDE (:RMX:inc/hi.ext)
- $INCLUDE (:RMX:inc/udi.ext)
-
- DECLARE buffer$tkn TOKEN,
- bufpool$tkn TOKEN,
- inbuffptr POINTER,
- index WORD,
- eh_handler EX_HANDLER_STRUCT,
- msg$info$struc MSG_INFO_STRUCT,
- port$info$struc PORT_INFO_STRUCT,
- port$tkn TOKEN,
- server$socket DWORD,
- server$socket$ovl STRUCTURE (psb$slot WORD,
- port$id WORD)
- AT (@server$socket),
- socket DWORD,
- status WORD,
- trans$id WORD;
-
- DECLARE count BYTE,
- data$buff(255) BYTE,
- message (*) BYTE DATA (21,'Message received is: '),
- message2 (*) BYTE DATA (22,'Converted message is: '),
- message3 (*) BYTE DATA (2,CR,LF,0);
-
-
-
- /**********************************************************************
- ************************ MAIN PROGRAM BEGINS *************************
- **********************************************************************/
- main:
-
- /* Set up the socket for the Client */
- server$socket$ovl.psb$slot = CLIENT$PSB$SLOT; /* Client PSB slot */
- server$socket$ovl.port$id = CLIENT$PORT$ID; /* Client Port ID */
-
- /* Enable in-line exception handling */
- CALL rq$get$exception$handler (@eh_handler,@status);
- eh_handler.mode = 0;
- CALL rq$set$exception$handler (@eh_handler,@status);
-
- /* Create the port object for this board */
- port$info$struc.portid = SERVER$PORT$ID; /* This Board */
- port$info$struc.type = DATA$SERVICE; /* Transport Protocol */
- port$info$struc.flags = FIFO$PORT$QUEUEING;
- port$info$struc.reserved = 0;
- port$tkn = rqcreate$port (2, @port$info$struc,@status);
- CALL check$exception (@(14,'rq$create$port'),status);
-
- /* Associate destination socket to port */
- CALL rq$connect (port$tkn,server$socket,@status);
- CALL check$exception (@(10,'rq$connect'),status);
-
- /* Create a buffer pool object */
- bufpool$tkn = rq$create$buffer$pool (30,0,@status);
- CALL check$exception (@(21,'rq$create$buffer$pool'),status);
-
- /* Attach the buffer pool to a default socket */
- CALL rq$attach$buffer$pool (bufpool$tkn,port$tkn,@status);
- CALL check$exception (@(21,'rq$attach$buffer$pool'),status);
-
- /* Create and release buffers to the buffer pool */
- DO count = 0 TO 5;
-
- /* Create a buffer */
- buffer$tkn = rq$create$segment (1024,@status);
- CALL check$exception (@(17,'rq$create$segment'),status);
-
- /* Release the buffer to the buffer pool */
- CALL rq$release$buffer (bufpool$tkn,buffer$tkn,0,@status);
- CALL check$exception (@(17,'rq$release$buffer'),status);
-
- END; /* DO count = 0 TO 5 */
-
-
- DO count = 0 TO 7;
-
- /* Get the message from the Client */
- inbuffptr = rq$receive (port$tkn,WAIT$FOREVER,@msg$info$struc,@status);
- CALL check$exception (@(10,'rq$receive'),status);
-
- /* Move buffer contents into program buffer. */
- CALL MOVB (inbuffptr,@data$buff,BYTE(msg$info$struc.data$length));
-
- /* Find buffer token of buffer used for the rq$receive system call */
- buffer$tkn = SELECTOR$OF(inbuffptr);
-
- /* Release the buffer back to the buffer pool */
- CALL rq$release$buffer (buf$pool$tkn,buffer$tkn,0,@status);
- CALL check$exception (@(17,'rq$release$buffer'),status);
-
- /* Display the original (encrypted) message received. */
- CALL rq$c$send$co$response (NIL,0,@message,@status);
- CALL check$exception (@(21,'rq$c$send$co$response'),status);
-
- /* The iRMX string form of the message is now in data$buff */
- CALL rq$c$send$co$response(NIL,0,@data$buff,@status);
- CALL check$exception( @(21,'rq$c$send$co$response'), status);
-
- /* Translate (decrypt) the message received */
- index = 1; /* Skip the count byte */
- DO WHILE ((data$buff(index) <> CR) AND (index < 255));
- data$buff(index) = decrypt (data$buff(index));
- index = index + 1;
- END;
-
-
- /* Display the decrypted message to the console */
- CALL rq$c$send$co$response (NIL,0,@message2,@status);
- CALL check$exception (@(21,'rq$c$send$co$response'),status);
-
- /* The iRMX string form of the message is now in data$buff */
- CALL rq$c$send$co$response (NIL,0,@data$buff,@status);
- CALL check$exception (@(21,'rq$c$send$co$response'),status);
-
- /* Force a new line */
- CALL rq$c$send$co$response (NIL,0,@message3,@status);
- CALL check$exception (@(21,'rq$c$send$co$response'),status);
-
- /* Return (send) the translated message back to the sender */
- trans$id = rq$send (port$tkn,server$socket,@msg$info$struc.control$msg,
- @data$buff,DWORD(data$buff(0))+1,0,@status);
- CALL check$exception (@(7,'rq$send'),status);
-
- END; /* DO count = 0 TO 7 */
-
- /* clean up */
- CALL rq$delete$port (port$tkn,@status);
- CALL check$exception (@(14,'rq$delete$port'),status);
-
- /* Exit gracefully */
- CALL rq$exit$io$job (0,NIL,@status);
- CALL check$exception (@(14,'rq$exit$io$job'),status);
-
- END server; /* End of module */
-