IBM Streams 4.2.1

Operator V1TCPSource

Primitive operator image not displayed. Problem loading file: ../../image/tk$spl/op$spl.compat$V1TCPSource.svg

The V1TCPSource operator reads binary data from a TCP socket that is connected to a InfoSphere Streams Version 1.2 TCP Sink operator and creates tuples from that data. It can be configured as a TCP server, which listens for a client connection, or as a TCP client, which initiates a connection to a server. In both modes, it handles a single connection at a time.

It works with both IPv4 and IPv6 addresses.

The corresponding V1TCPSink operator must have a binFormat modifier to send the data in binary form. The V1TCPSource operator is defined in the spl.compat namespace, and must be included through a use spl.compat::V1TCPSource; statement.

Exceptions

The V1TCPSource operator throws an exception in the following cases:
  • The host cannot be resolved.
  • Unable to set SO_REUSEADDR on TCP socket.
  • Unable to bind to port.

Examples

This example uses the V1TCPSource operator.

composite Main {                                                                        
  graph                                                                                 
    // Read from an InfoSphere Streams V1.2 system                                      
    stream<rstring name, int32 age, int64 salary> v1Data = spl.compat::V1TCPSource()    
    {                                                                                   
       param port : 4000u;                                                              
             role : server;                                                             
    }                                                                                   
}                                                

The following example is the corresponding V1.2 TCP Source:

stream FromV2 (schemaFor(T)) :=                                   
Source() ["stcp://thishost:4001/", binFormat] {}                   

Summary

Ports
This operator has 0 input ports and 1 output port.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 7 parameters.

Required: role

Optional: address, initDelay, port, receiveBufferSize, reconnectionBound, reconnectionPolicy

Metrics
This operator reports 2 metrics.

Properties

Implementation
C++
Threading
Always - Operator always provides a single threaded execution context.

Output Ports

Assignments
This operator allows any SPL expression of the correct type to be assigned to output attributes.
Ports (0)

The V1TCPSource operator is configurable with a single output port, which produces tuples read over a TCP connection from a V1.x system. The V1TCPSource operator outputs a window marker punctuation when a TCP connection terminates. The tuple that is generated by the V1TCPSource operator must contain attributes of supported SPL types only.

Properties

Parameters

This operator supports 7 parameters.

Required: role

Optional: address, initDelay, port, receiveBufferSize, reconnectionBound, reconnectionPolicy

address

For a client-based V1TCPSource operator, this parameter specifies the destination address of the TCP connection. This parameter must be specified when the role parameter value is client.

The parameter value can be a host name or an IP address.

For a server-based V1TCPSource operator, this parameter is not valid.

Properties

initDelay

Specifies the number of seconds to delay before starting to produce tuples. For more information, see the initDelay parameter in the spl.adapter::FileSource operator.

Properties

port

For a client-based V1TCPSource operator, this parameter specifies the destination port address. It takes a single value of type rstring or uint32. This value can be a well-known port alias, such as "http" or "ftp", as specified in /etc/services. It can also be a plain port number, such as 45134u.

For a server-based V1TCPSource operator, this parameter specifies the port address on which the connections are accepted. When the parameter is omitted, its default value is 0, which picks any available port.

Properties

receiveBufferSize

Specifies the kernel receive buffer size for the TCP socket.

Properties

reconnectionBound

Specifies the number of successive connections that are attempted for a client-based V1TCPSource operator or accepted for a server-based V1TCPSource operator.

You must specify this parameter when the reconnectionPolicy parameter value is BoundedRetry; you cannot use it otherwise.

Properties

reconnectionPolicy

Specifies the reconnection policy. For a server-based V1TCPSource operator, this parameter specifies whether more connections are allowed after the initial connection terminates. For a client-based V1TCPSource operator, this parameter specifies whether more connection attempts are made after the initial connection to the server terminates.

The valid values are: NoRetry, InfiniteRetry, and BoundedRetry. If this parameter is not specified, it is set to InfiniteRetry.

When the parameter value is NoRetry, the V1TCPSource operator produces a final marker punctuation right away after the initial connection is terminated and a window marker punctuation is sent.

Properties

role

Specifies whether the operator is server-based or client-based. It takes one of the following two values: server or client.

Properties

Metrics

nInvalidTuples - Counter

The number of tuples that failed to read correctly in csv or txt format.

nReconnections - Counter

The number of times the input connection was re-establised.

Libraries

spl-std-tk-lib
Library Name: streams-stdtk-runtime
Include Path: ../../../impl/include