跳到主要内容

3. 数据流格式

客户端和服务器之间交换的实际数据流由一个头部后跟 5250 工作站数据流组成. 有关 5250 工作站数据流的信息, 请参阅 IBM 5250 Information Display System, Functions Reference Manual (SA21-9247). 作为 5250 数据流前缀的该头部最初是为 5250 Display Station Pass-Through (DSPT) 应用设计的. 5250 DSPT 是一种类似于 Telnet 的应用, 在 SNA 网络上运行于 IBM AS/400, System/36 和 System/38. 该头部设计为可变长度, 由两部分组成. 第一部分是固定部分, 始终为 6 个八位组长, 格式如下:

 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Logical Record Length | Record Type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

逻辑记录长度 (Logical Record Length): 16 位

此字段指示此逻辑记录的长度 (以八位组为单位), 包括头部长度. 该长度是在将数据流中的任何 IAC 字符加倍之前计算的. 该长度不包括追加到数据流末尾以标记此逻辑记录结束的 . 该长度以最高有效八位组在前的方式指定. 例如, 长度 36 (十进制) 将指定为 '0024'X.

记录类型 (Record Type): 16 位

此字段指示 SNA 记录类型. 它应始终设置为 '12A0'X, 以指示 General Data Stream (GDS) 记录类型.

保留 (Reserved): 16 位

此字段当前未使用.

头部的第二部分设计为可变长度. 该可变部分的长度在第一个八位组中指定. 目前, 头部的这一部分始终为 4 个八位组长, 格式如下:

 0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |E|A| | | |S|T|H| | |
| Var Hdr Len |R|T| | | |R|R|L| | Opcode |
| |R|N| | | |Q|Q|P| | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

可变头部长度 (Var Hdr Len): 8 位

头部可变部分的长度 (以八位组为单位). 目前始终为 '04'X.

标志 (Flags): 16 位

Bit 0:      ERR     This bit is set to indicate a data stream
output error. The negative response code
is sent as data following the opcode field.
Bit 1: ATN This bit is set to indicate that the 5250
attention key was pressed.
Bits 2-4: * These bits are reserved (set to zero).
Bit 5: SRQ This bit is set to indicate that the 5250
System Request key was pressed.
Bit 6: TRQ This bit is set to indicate that the 5250
Test Request key was pressed.
Bit 7: HLP This bit is set to indicate the Help in
Error State function. The error code is
sent as data following the header and is
a four digit packed decimal number. For
example, an error code of '0005'X indicates
the operator attempted to type in an area of
the display that is not enabled for input.
Bits 8-15: * These bits are reserved (set to zero).

操作码 (Opcode): 8 位

此字段包含操作码. 它被设置为指示发送方请求的操作类型. 以下是有效值:

'00'X:  No Operation
'01'X: Invite Operation
'02'X: Output Only
'03'X: Put/Get Operation
'04'X: Save Screen Operation
'05'X: Restore Screen Operation
'06'X: Read Immediate Operation
'07'X: Reserved
'08'X: Read Screen Operation
'09'X: Reserved
'0A'X: Cancel Invite Operation
'0B'X: Turn On Message Light
'0C'X: Turn Off Message Light

实际的 5250 工作站数据流将紧跟在头部中的操作码字段之后, 并以 对终止. 对于某些操作, 头部之后将紧跟一个 , 中间没有任何 5250 工作站数据流. 例如, 服务器可以发送以下开启消息灯的请求:

000A 12A0 0000 0400 000B FFEF
| | | | | | |
| | | | | | End Of Record marker
| | | | | |
| | | | | Opcode = Turn On Message Light ('0B'X)
| | | | |
| | | | Flags = '0000'X
| | | |
| | | Variable Header Length = '04'X
| | |
| | Reserved - Set to '0000'X
| |
| Record Type = General Data Stream ('12A0'X)
|
Logical Record Length = '000A'X for this record

在此示例中, 请求的操作由操作码指示, 并且没有关联的工作站数据流.