$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 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 CLIENT$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. Prompt the user for a string of characters (the message). ** ** ** ** 4. Encrypt the message (the message will be placed in the ** ** control section of the packet to be sent to board in slot ** ** SERVER$PSB$SLOT). ** ** ** ** 5. Send the encrypted message to the board in slot ** ** SERVER$PSB$SLOT. (The message is sent asynchronously) ** ** ** ** 6. Wait to receive the decrypted message back from board in ** ** slot SERVER$PSB$SLOT. ** ** ** ** 7. Display the message received to the console. ** ** ** ** 8. Repeat steps 3 - 8. ** ** ** ** ** ***********************************************************************/ client: 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 inbuffptr POINTER, msg$info$struc MSG_INFO_STRUCT, port$info$struc PORT_INFO_STRUCT, port$tkn TOKEN, server$socket DWORD, socket DWORD, status WORD, trans$id WORD, eh_handler EX_HANDLER_STRUCT, control$msg$buff (20) BYTE, count BYTE, index BYTE, server$socket$ovl STRUCTURE (psb$slot WORD, port$id WORD) AT (@server$socket), message (*) BYTE DATA (32,'Enter any string of characters: '), message2 (*) BYTE DATA (21,'Message received is: '), message3 (*) BYTE DATA (2,CR,LF,0); /********************************************************************** ************************ MAIN PROGRAM BEGINS ************************* **********************************************************************/ main: /* 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 = CLIENT$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 = rq$create$port (2, @port$info$struc,@status); CALL check$exception (@(14,'rq$create$port'), status); /* Set up the socket for the Server */ server$socket$ovl.psb$slot = SERVER$PSB$SLOT; /* Server PSB slot */ server$socket$ovl.port$id = SERVER$PORT$ID; /* Server Port ID */ /* Create a default socket to get to the board in slot SERVER$PSB$SLOT. */ CALL rq$connect (port$tkn,server$socket,@status); CALL check$exception (@(10,'rq$connect'), status); DO count = 0 TO 5; CALL rq$c$send$co$response (@control$msg$buff,19,@message,@status); CALL check$exception (@(21,'rq$c$send$co$response'), status); /* Encrypt the message before sending it */ index = 1; /* Skip the count byte */ DO WHILE ((control$msg$buff(index) <> CR) AND (index < 20)); control$msg$buff (index) = encrypt (control$msg$buff(index)); index = index + 1; END; /* Send the mesage to the Server. * The control portion of the message will hold the message. */ trans$id = rq$send (port$tkn,server$socket,@control$msg$buff, NIL,0,0,@status); CALL check$exception (@(7,'rq$send'),status); /* Receive the converted message from the Server. */ inbuffptr = rq$receive (port$tkn,WAIT$FOREVER,@msg$info$struc,@status); CALL check$exception (@(10,'rq$receive'),status); /* Display the received message */ CALL rq$c$send$co$response (NIL,0,@message2,@status); CALL check$exception (@(21,'rq$c$send$co$response'),status); /* Message is contained in the control buffer */ CALL rq$c$send$co$response (NIL,0,@msg$info$struc.control$msg,@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); 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 client; /* End of module */