multiplexer - One-to-many communication with sockets.
The multiplexer package provides a generic system for one-to-many communication utilizing sockets. For example, think of a chat system where one user sends a message which is then broadcast to all the other connected users.
It is possible to have different multiplexers running concurrently.
The create command creates a new multiplexer 'instance'. For example:
set mp [::multiplexer::create]
This instance can then be manipulated like so:
${mp}::Init 35100
This starts the multiplexer listening on the specified port.
Use Config to configure the multiplexer instance. Configuration options currently include:
Command to add a filter for data that passes through the multiplexer instance. The registered cmdprefix is called when data arrives at a multiplexer instance. If there is more than one filter command registered at the instance they will be called in the order of registristation, and each filter will get the result of the preceding filter as its argument. The first filter gets the incoming data as its argument. The result returned by the last filter is the data which will be broadcast to all clients of the multiplexer instance. The command prefix is called as
Takes the incoming data, modifies it, and returns that as its result. The last three arguments contain information about the client which sent the data to filter: The channel connecting us to the client, its ip-address, and its ip-port.
Command to add an access filter. The registered cmdprefix is called when a new client socket tries to connect to the multixer instance. If there is more than one access filter command registered at the instance they will be called in the order of registristation. If any of the called commands returns -1 the access to the multiplexer instance is denied and the client channel is closed immediately. Any other result grants the client access to the multiplexer instance. The command prefix is called as
The arguments contain information about the client which tries to connected to the instance: The channel connecting us to the client, its ip-address, and its ip-port.
Adds filter to be run when client socket generates an EOF condition. The registered cmdprefix is called when a client socket of the multixer signals EOF. If there is more than one exit filter command registered at the instance they will be called in the order of registristation. Errors thrown by an exit filter are ignored, but logged. Any result returned by an exit filter is ignored. The command prefix is called as
The arguments contain information about the client which signaled the EOF: The channel connecting us to the client, its ip-address, and its ip-port.
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category multiplexer of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
Programming tools