home *** CD-ROM | disk | FTP | other *** search
- Specifications for communications with Os2You via pipes.
- ========================================================
-
-
- The pipe format
- ===============
- Os2You creates a named pipe with unlimited pipe instances possible.
- The pipe is a full duplex message pipe with no write behind allowed.
- Os2You tries to allocate a 16 Kbyte output buffer and 1 Kbyte input
- buffer, but will work with any buffer size actually supplied by the
- API.
-
- If the pipe is broken by Os2You, this will mean that Os2You has ended
- the conversion with the terminal program.
-
- If the pipe is broken by the terminal program during a conversion,
- Os2You will treat this as a carrier loss, and try to end the running
- program, and the current remote session.
-
-
-
-
- Reading the pipe
- ================
- A terminal program wishing to communicate with Os2You via pipes should
- preferable open the pipe in blocking mode and in message read mode. Note
- that when coding for a single tasking environment (like DOS), it might be
- necessary to use non blocking mode, as you have to serve writing, even if
- you don't get anything reading the pipe. It is possible to put the Os2You
- program in "Anti blocking mode", which means that Os2You will send "empty"
- messages (=Flag set to 0) to prevent blocking when reading the pipe. This
- is done by sending first Esc and then zero (1Bh, 00h). A message will
- have the following structure:
-
- RECORD
- Flag : CHAR; (* One byte character *)
- CurRow : CARDINAL; (* Two byte unsigned integer *)
- CurCol : CARDINAL; (* Two byte unsigned integer *)
- Length : CARDINAL; (* Two byte unsigned integer *)
- Reserved : ARRAY [1..30000] OF CHAR; (* 30000 byte character buffer *)
- END;
-
- The message is of variable size. When a message is received, the Flag
- character will reflect the type of message received.
-
- If <Flag> is set to 00H this indicates the session begins. No special
- action is required of the terminal program, but it might send a Esc-b
- sequence to set Os2You to binary screen mode.
-
- If <Flag> is set to 01H this indicates a cursor position command. The
- <CurRow> and <CurCol> parameters will contain the cursor positions the
- terminal program should set. If the <Length> value is non-zero a new
- message will follow immidiatly, containing a direct image of the video
- buffer. The whole message (or as much of it that is allowed by the
- terminal programs screen size), should be placed in the logical video
- buffer, and be displayed. Note, that if <CurRow> and <CurCol> both
- are set to 65535 (all bits set), this means that the Os2You session
- is ending.
-
- If <Flag> is set to any other value than 00H or 01H, the whole message
- will contain text that should be displayed at the screen with a ordinary
- write command. It might contain ANSI-sequences, so your terminal program
- should set the ANSI-mode on.
-
- If the terminal can't read the pipe in message mode, it is still
- possible to get all functionality using ordinary byte stream mode,
- although this will require more coding. It is recommended to use
- non blocking mode when writing DOS-applications as DOS is not re-
- entrant and you can't write to the pipe, while the program is blocked
- in a read operation. The program should behave in the following manner:
-
- Read a block of any size from the pipe. Scan and retain the position
- for the first occurance of a 00H byte in the block. Scan and retain
- the position for the first occurance of a 01H byte in the block.
-
- Write the characters before the first occurance of 00H or 01H byte to
- screen, using ordinary write-commands.
-
- If the position for the 00H byte is less than the position for 01H
- byte, a <Flag> of 00H is assumed, and proper action is taken.
-
- If the position for the 01H byte is less than 00H byte a <Flag> of 01H is
- assumed. Assure that you have at least six characters following the
- <Flag> byte, and map them to the message block showed above. Set the
- cursor position according to this. If the <Length> value is set in
- this block, you should read <Length> bytes further (including any
- previous read bytes not used yet), and move these bytes directly to
- video memory.
-
- Any trailing characters not yet used by previous decoding, should be
- rescanned and decoded again, until there are no 00H or 01H bytes in
- the remaining block. This remaining block should then be displayed
- using ordinary write commands.
-
- Note, that OS/2 1.2 and Lan Server 1.2 didn't work correctly sometimes
- when reading large messages from a remote pipe. Therefore you should
- limit your pipe reads to maximum 4 kByte reads, and merge the next
- read with the current if you get the ERRROR_MORE_DATA error.
-
-
-
-
-
- Writing to the pipe
- ===================
- To send characters to Os2You, the terminal program should send messages of
- the length one byte, containing the ASCII-code of the character sent to
- Os2You. It is important that no messages longer than 1 byte are sent to
- over the pipe, as Os2You will just ignore the remaining part of the message
- or treat it as an invalid client, and end the conversion. The same Esc-
- sequences as described in the documentations are used when using pipes.
-
-
-
-
- Examples
- ========
- Here is an example on how the read pipe (message mode) thread looks like
- in Lanterm2.Mod:
-
- LOOP
- BytesRead := PipeRead(); (* Read Pipe and place result in Buffer *)
- CASE Buffer.Flag OF
- | CHR(0) : TempCh := CHR(27);
- IF Dos.Write(Handle,ADR(TempCh),1,BytesWritten) = 0 THEN END;
- TempCh := 'b';
- IF Dos.Write(Handle,ADR(TempCh),1,BytesWritten) = 0 THEN END;
- | CHR(1) : IF Vio.SetCurPos(Buffer.CurRow,Buffer.CurCol,0) = 0 THEN END;
- IF Buffer.Length <> 0 THEN
- BytesRead := PipeRead();
- IF BytesRead > ScrLen THEN
- Lib.WordMove(ADR(Buffer),LVBPtr,ScrLen DIV 2);
- ELSE
- Lib.WordMove(ADR(Buffer),LVBPtr,BytesRead DIV 2);
- END;
- IF Vio.ShowBuf(0,ScrLen,0) = 0 THEN END;
- END;
- ELSE IF Vio.WrtTTY(ADR(Buffer),BytesRead,0) = 0 THEN END;
- END;
- END;