[ Tcllib Table Of Contents | Tcllib Index ]
transfer::transmitter(n) 0.2 "Data transfer facilities"
transfer::transmitter - Data source
- package require Tcl 8.4
- package require snit ?1.0?
- package require transfer::copy ?0.2?
- package require transfer::data::source ?0.2?
- package require transfer::connect ?0.2?
- package require transfer::transmitter ?0.2?
This package pulls data sources and connection setup together into a combined object for the transmission of information over a socket. These objects understand all the options from objects created by the packages transfer::data::source and transfer::connect.
- transfer::transmitter objectName ?options...?
This command creates a new transmitter object with an associated Tcl command whose name is objectName. This object command is explained in full detail in the sections Object command and Object methods. The set of supported options is explained in section Options.
The object command will be created under the current namespace if the objectName is not fully qualified, and in the specified namespace otherwise. The fully qualified name of the object command is returned as the result of the command.
- transfer::transmitter stream channel chan host port ?arg...?
This method creates a fire-and-forget transfer for the data contained in the channel chan, starting at the current seek location. The channel is configured to use binary translation and encoding for the transfer. The channel is automatically closed when the transfer has completed.
If both host and port are provided an active connection to the destination is made. If only a port is specified (with host the empty string) then a passive connection is made instead.
Any arguments after the port are treated as options and are used to configure the internal transmitter object. See the section Options for a list of the supported options and their meaning. Note however that the signature of the command prefix specified for the -command callback differs from the signature for the same option of the transmitter object. This callback is only given the number of bytes and transfered, and possibly an error message. No reference to the internally used transmitter object is made.
The result returned by the command is the empty string if it was set to make an active connection, and the port the internal transmitter object is listening on otherwise, i.e when it is configured to connect passively. See also the package transfer::connect and the description of the method connect for where this behaviour comes from.
- transfer::transmitter stream file path host port ?arg...?
This method is like stream channel, except that the data contained in the file path is transfered.
All objects created by the ::transfer::transmitter command have the following general form:
- objectName destroy
This method destroys the object. Doing so while a transmission is in progress will cause errors later on, when the transmission completes and tries to access the now missing data structures of the destroyed object.
- objectName start
This method initiates the data transmission, setting up the connection first and then copying the information. The method will throw an error if a transmission is already/still in progress. I.e. it is not possible to run two transmissions in parallel on a single object, only in sequence. Multiple transmitter objects are needed to manage parallel transfers, one per transmission. Errors will also be thrown if the configuration of the data source is invalid, or if no completion callback was specified.
The result returned by the method is the empty string for an object configured to make an active connection, and the port the object is listening on otherwise, i.e when it is configured to connect passively. See also the package transfer::connect and the description of the method connect for where this behaviour comes from.
- objectName busy
This method returns a boolean value telling us whether a transmission is in progress (True), or not (False).
One way to secure connections made by objects of this package is to require the package tls and then configure the option -socketcmd to force the use of command tls::socket to open the socket.
# Load and initialize tls package require tls tls::init -cafile /path/to/ca/cert -keyfile ... # Create a connector with secure socket setup, transfer::transmitter T -socketcmd tls::socket ... ...
This package uses the TLS package to handle the security for https urls and other socket connections.
Policy decisions like the set of protocols to support and what ciphers to use are not the responsibility of TLS, nor of this package itself however. Such decisions are the responsibility of whichever application is using the package, and are likely influenced by the set of servers the application will talk to as well.
For example, in light of the recent POODLE attack discovered by Google many servers will disable support for the SSLv3 protocol. To handle this change the applications using TLS must be patched, and not this package, nor TLS itself. Such a patch may be as simple as generally activating tls1 support, as shown in the example below.
package require tls tls::init -tls1 1 ;# forcibly activate support for the TLS1 protocol ... your own application code ...
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category transfer of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
Copyright © 2006-2009 Andreas Kupries <firstname.lastname@example.org>