Read TCP Data

Read TCP Data is an asynchronous activity that reads data from an open TCP connection. The connection must be opened by an activity or a process starter that executed previously in the process.

General

Activities that can open a TCP connection are: TCP Receiver, TCP Open Connection, and Wait for TCP Request. The activity that opens a TCP connection places a handle to the open connection in its connectionKey output element. The connectionKey is mapped to this activity’s input.

The General tab has the following fields.

Field Literal Value/Module Property/Process Property Description
Name None The name to be displayed as the label for the activity in the process.
Type None Type of data to be read. This can be either Text or Binary.

Specifying Text in this field enables the Separator and Encoding fields. When Binary is specified, the Bytes To Read field is enabled.

Separator Yes The type of separator. This activity reads data from the TCP connection until the separator or the end of the data stream is encountered.

Select User-defined binary separator (specify comma-separated byte values) from the drop-down list to enable the User Defined Separator field.

User Defined Separator Yes This field specifies the separator character to use.
When Binary is selected in the Type field, a user-defined separator can be:
  • A string representation of a single byte, or
  • A comma-separated byte values (for example, 0x0a, 0x0b, 0x0c, and so on).
For valid string representations of byte values, refer to the Java documentation for the decode(String n) method of Java.lang.Byte.
Encoding Yes Specifying Text in the Type field, determines the character encoding of the text data in this field.
Bytes To Read Yes Specify the number of bytes to be read by this activity.

This field is enabled when you select Binary in the Type field.

Leaving this field blank makes the activity read until the end of the data stream is encountered.

Timeout (msec) Yes The time to wait (in milliseconds) for this activity to complete.

Description

Provide a short description for the activity.

Input

The following is the input for the activity.

Note: When Text is specified in the Type field, the Input tab displays connection, encoding, separator, and timeout elements. Specifying Binary in the Type field displays connection, bytesToRead, and timeout elements.
Input Item Datatype Description
connection binary The handle to the connection to read the data from.

This connection is obtained from a previously executed activity in the process that opened the connection.

encoding string Specifies the character encoding of the text when reading the text data.

This value overrides the value specified in the Encoding field in the General tab.

separator string An optional element. Specifies the boundary between the body elements after writing the body element to the TCP connection, while reading the text data.

This element is available only when the User Defined Separator option is selected on the General tab.

This value overrides the value specified in the General tab.

bytesToRead number An optional element. Specifies the number of bytes to be read when reading the binary data.

This value overrides the value specified in the Bytes To Read field in the General tab.

timeout number An optional element. The time to wait (in milliseconds) for this activity to complete.

Output

The following is the output of the activity.

Output Item Datatype Description
data string When the data is specified as text, this output element contains the text read from the TCP connection. The separator character if specified, is not included in the output.

When the data is specified as binary, this output element contains the binary data read from the TCP connection.

endOfStreamReached boolean This element is set to true, when the end of the data stream is reached.

This is useful when the activity is in an iteration loop and the activity is configured to read a number of bytes with each iteration. Use this element in the condition of the loop, to determine when the last set of bytes was read.

Fault

The Fault tab lists the possible exceptions generated by this activity. For more information about error codes and the corrective action to take, see the TIBCO ActiveMatrix BusinessWorks™ Error Codes guide.

Fault Generated When..
TCPActivityFault There is some problem associated with the activity at runtime.