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 unsolicited messages (messages whose data **
- ** field is set to NULL) using the iRMX II/III Operating **
- ** Systems. **
- ** **
- ** **
- ** **
- ** USAGE: **
- ** **
- ** This program can be executed on any MULTIBUS-II board **
- ** running the iRMX II/III Operating Systems. **
- ** 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. Receive an encrypted message from the board in slot **
- ** CLIENT$PSB$SLOT. **
- ** **
- ** 4. Display the message received in the encrypted form. **
- ** **
- ** 5. Decrypt the message received and display it at the console. **
- ** **
- ** 6. Send the decrypted message back to the board in slot **
- ** CLIENT$PSB$SLOT. **
- ** **
- ** 7. Repeat steps 3 - 7. **
- ** **
- ** **
- ***********************************************************************/
-
- 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 TOKEN,
- eh_handler EX_HANDLER_STRUCT,
- inbuffptr POINTER,
- index WORD,
- msg$info$buff MSG_INFO_STRUCT,
- port$tkn TOKEN,
- port$info$struc PORT_INFO_STRUCT,
- server$socket DWORD,
- socket DWORD,
- status WORD,
- trans$id WORD,
- control$ptr(16) BYTE,
- count BYTE,
- server$socket$ovl STRUCTURE (psb$slot WORD,
- port$id WORD)
- AT (@server$socket),
- message (*) BYTE DATA (20,'MESSAGE RECEIVE IS: '),
- message2 (*) BYTE DATA (19,'CONVERTED MESSAGE: '),
- 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);
-
- DO count = 0 TO 5;
-
- /* Get the message from the Client */
- inbuffptr = rq$receive (port$tkn,WAIT$FOREVER,@msg$info$buff,@status);
- CALL check$exception (@(10,'rq$receive'),status);
-
- /* Display message received in original form */
- CALL rq$c$send$co$response (nil,0,@message,@status);
- CALL check$exception (@(21,'rq$c$send$co$response'),status);
-
- /* Message is contained in the control field */
- CALL rq$c$send$co$response (nil,0,@msg$info$buff.controlmsg,@status);
- CALL check$exception (@(21,'rq$c$send$co$response'),status);
-
- /* Translate (decrypt) the message received */
- index = 1; /* Skip the count byte */
- DO WHILE ((msg$info$buff.controlmsg(index) <> CR) AND (index < 20));
- msg$info$buff.controlmsg(index) =
- decrypt (msg$info$buff.controlmsg(index));
- index = index + 1;
- END;
-
- /* Display decrypted message */
- CALL rq$c$send$co$response (nil,0,@message2,@status);
- CALL check$exception (@(21,'rq$c$send$co$response'),status);
-
- /* Message is in control buffer */
- CALL rq$c$send$co$response (nil,0,@msg$info$buff.controlmsg,@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 decrypted message back to the sender */
- trans$id = rq$send (port$tkn,server$socket,@msg$info$buff.controlmsg,
- nil,0,0,@status);
- CALL check$exception (@(7,'rq$send'),status);
-
- END; /* DO count = 0 TO 5 */
-
- /* 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 */
-