|
|
TCP ConnectorOverviewThe TCPConnector is a transport Connector using TCP sockets for transport. You can only use the Connector in Iterator and AddOnly mode. Iterator ModeWhen using the Connector in Iterator mode the Connector waits for incoming TCP calls on a specific port. When a connection is established the getnext method returns an entry with the following properties:
The in and out objects can be used to read and write data from/to the TCP connection. For example, you can do the following to implement a simple echo server. Put the code in your after-getnext hook:
Since you are using a BufferedWriter it is important to call the out.flush() method to make sure data is actually sent out on the connection. If you specify a Parser then the BufferedReader will be passed to the Parser which in turn reads and interprets data sent on the stream. The returned entry will then include any attributes assigned by the Parser as well as the properties listed above. If the Connector is configured in serverMode=true then the connection will be closed between each call to the getnext method. If serverMode=false the connection to the remote host will be kept open for as long as the Connector is active (e.g. until the AssemblyLine terminates). AddOnly ModeWhen the Connector works in this mode the default implementation is to write entries in their string form which is not very useful. Typically, you will specify a Parser or use the override-add hook to do specific output. In the override-add hook you access the in/out objects by calling the raw-Connector's getReader() and getWriter() methods as in:
You can also use the before-add and after-add hooks to insert headers/footers around the output from your Parser. Configuration
See Also
|
|
|