Simple Threaded TCP Client
This component is for making a TCP connection to a server. Send to its "inbox" inbox to send data to the server. Pick up data received from the server on its "outbox" outbox.
This component runs in its own separate thread so it can block on the socket connection. This was written because some platforms that don't support non-blocking calls to read/write data from sockets (eg. Python for Nokia Series-60).
Sending the contents of a file to a server at address 188.8.131.52 on port 1000:
Pipeline( RateControlledFileReader("myfile", rate=100000), ThreadedTCPClient("184.108.40.206", 1000), ).activate()
The component opens a socket connection to the specified server on the specified port. Data received over the connection appears at the component's "outbox" outbox as strings. Data can be sent as strings by sending it to the "inbox" inbox.
The component will shutdown in response to a producerFinished message arriving on its "control" inbox. The socket will be closed, and a socketShutdown message will be sent to the "signal" outbox.
All socket errors exceptions are passed on out of the "signal" outbox. This will always result in the socket being closed (if open) and a socketShutdown message also being sent to the "signal" outbox (after the exception).
It does not use a ConnectedSocketAdapter, instead handling all socket communications itself.
The compnent is based on Axon.ThreadedComponent.threadedcomponent
ThreadedTCPClient(host,port[,chargen][,initalsendmessage]) -> threaded component with a TCP connection to a server.
Establishes a TCP connection to the specified server.
Methods defined here
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Main (thread) loop
Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!
Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.
-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)
(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved.