Managing TCP Connections
The TCP activities are designed to work with custom applications that communicate with other applications via TCP. This sample shows how to perform common tasks, such as opening a connection, writing data to it, and closing the connection.
Procedure
Result
The TCP_Basic.log file is generated at C:\tmp\TCP_Basic contains the following data.
Test Request Data by iterationLoop- 1
Test Request Data by iterationLoop- 2
Test Request Data by iterationLoop- 3
Test Request Data by iterationLoop- 4
Test Request Data by noSeparator
Test Reply Data by noSeparator
Test Request Data by preDefinedSeparator
Test Reply Data by preDefinedSeparator
Test Request Data by userDefinedSeparator
Test Reply Data by userDefinedSeparator
Test Request Data by binarySeparator
Test Reply Data by binarySeparator
The Console view displays the output similar to the following.
10:40:20.505 INFO [bwThread:In-Memory STWorkProcessor-1] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest - Test Request Data by iterationLoop- 1
10:40:20.545 INFO [bwThread:In-Memory STWorkProcessor-5] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest - Test Request Data by iterationLoop- 2
10:40:20.568 INFO [bwThread:In-Memory STWorkProcessor-7] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest - Test Request Data by iterationLoop- 3
10:40:20.593 INFO [bwThread:In-Memory STWorkProcessor-8] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest - Test Request Data by iterationLoop- 4
10:40:20.618 INFO [bwThread:In-Memory STWorkProcessor-2] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest -
10:40:21.447 INFO [bwThread:In-Memory STWorkProcessor-1] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest - Test Request Data by noSeparator
10:40:21.491 INFO [bwThread:In-Memory STWorkProcessor-7] c.t.b.p.g.L.t.b.s.p.t.B.PrintReply - Test Reply Data by noSeparator
10:40:22.428 INFO [bwThread:In-Memory STWorkProcessor-4] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest - Test Request Data by preDefinedSeparator
10:40:22.460 INFO [bwThread:In-Memory STWorkProcessor-3] c.t.b.p.g.L.t.b.s.p.t.B.PrintReply - Test Reply Data by preDefinedSeparator
10:40:23.429 INFO [bwThread:In-Memory STWorkProcessor-2] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest - Test Request Data by userDefinedSeparator
10:40:23.445 INFO [bwThread:In-Memory STWorkProcessor-6] c.t.b.p.g.L.t.b.s.p.t.B.PrintReply - Test Reply Data by userDefinedSeparator
10:40:24.429 INFO [bwThread:In-Memory STWorkProcessor-7] c.t.b.p.g.L.t.b.s.p.t.B.PrintRequest - Test Request Data by binarySeparator
10:40:24.467 INFO [bwThread:In-Memory STWorkProcessor-8] c.t.b.p.g.L.t.b.s.p.t.B.PrintReply - Test Reply Data by binarySeparator
Understanding the Configuration
The following TCP palette activities are used in this sample:
- TCP Receiver: The process starter starts a new process, when a client requests a TCP connection.
- Wait for TCP Request: The activity waits for a TCP client connection request.
- TCP Open Connection: The activity opens a connection to a TCP server.
- TCP Close Connection: The activity closes a TCP connection opened by a previously executed activity or process starter.
- Write TCP Data: The activity sends data on the specified TCP connection.
- Read TCP Data: The activity reads data from an open TCP connection.
The processes show the use of Binary and Text modes.