August'24: Kamaelia is in maintenance mode and will recieve periodic updates, about twice a year, primarily targeted around Python 3 and ecosystem compatibility. PRs are always welcome. Latest Release: 1.14.32 (2024/3/24)
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 1.2.3.4 on port 1000:
Pipeline( RateControlledFileReader("myfile", rate=100000),
ThreadedTCPClient("1.2.3.4", 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.
Keyword arguments:
Warning!
You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.
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