1. Carl Meyer
  2. cpython-robust-site


cpython-robust-site / Doc / libctb.tex

The branch 'legacy-trunk' does not exist.
\section{Built-in Module \sectcode{ctb}}
\renewcommand{\indexsubitem}{(in module ctb)}

This module provides a partial interface to the Macintosh
Communications Toolbox. Currently, only Connection Manager tools are
supported.  It may not be available in all Mac Python versions.

The exception raised on errors.

Flags for the \var{channel} argument of the \var{Read} and \var{Write}

End-of-message flag for \var{Read} and \var{Write}.

Values returned by \var{Choose}.

Bits in the status as returned by \var{Status}.

Return 1 if the communication toolbox is available, zero otherwise.

\begin{funcdesc}{CMNew}{name\, sizes}
Create a connection object using the connection tool named
\var{name}. \var{sizes} is a 6-tuple given buffer sizes for data in,
data out, control in, control out, attention in and attention out.
Alternatively, passing \code{None} will result in default buffer sizes.

\subsection{connection object}
For all connection methods that take a \var{timeout} argument, a value
of \code{-1} is indefinite, meaning that the command runs to completion.

\renewcommand{\indexsubitem}{(connection object attribute)}

If this member is set to a value other than \code{None} it should point
to a function accepting a single argument (the connection
object). This will make all connection object methods work
asynchronously, with the callback routine being called upon

{\em Note:} for reasons beyond my understanding the callback routine
is currently never called. You are advised against using asynchronous
calls for the time being.

\renewcommand{\indexsubitem}{(connection object method)}

Open an outgoing connection, waiting at most \var{timeout} seconds for
the connection to be established.

Wait for an incoming connection. Stop waiting after \var{timeout}
seconds. This call is only meaningful to some tools.

Accept (when \var{yesno} is non-zero) or reject an incoming call after
\var{Listen} returned.

\begin{funcdesc}{Close}{timeout\, now}
Close a connection. When \var{now} is zero, the close is orderly
(i.e.\ outstanding output is flushed, etc.)\ with a timeout of
\var{timeout} seconds. When \var{now} is non-zero the close is
immediate, discarding output.

\begin{funcdesc}{Read}{len\, chan\, timeout}
Read \var{len} bytes, or until \var{timeout} seconds have passed, from
the channel \var{chan} (which is one of \var{cmData}, \var{cmCntl} or
\var{cmAttn}). Return a 2-tuple:\ the data read and the end-of-message

\begin{funcdesc}{Write}{buf\, chan\, timeout\, eom}
Write \var{buf} to channel \var{chan}, aborting after \var{timeout}
seconds. When \var{eom} has the value \var{cmFlagsEOM} an
end-of-message indicator will be written after the data (if this
concept has a meaning for this communication tool). The method returns
the number of bytes written.

Return connection status as the 2-tuple \code{(\var{sizes},
\var{flags})}. \var{sizes} is a 6-tuple giving the actual buffer sizes used
(see \var{CMNew}), \var{flags} is a set of bits describing the state
of the connection.

Return the configuration string of the communication tool. These
configuration strings are tool-dependent, but usually easily parsed
and modified.

Set the configuration string for the tool. The strings are parsed
left-to-right, with later values taking precedence. This means
individual configuration parameters can be modified by simply appending
something like \code{'baud 4800'} to the end of the string returned by
\var{GetConfig} and passing that to this method. The method returns
the number of characters actually parsed by the tool before it
encountered an error (or completed successfully).

Present the user with a dialog to choose a communication tool and
configure it. If there is an outstanding connection some choices (like
selecting a different tool) may cause the connection to be
aborted. The return value (one of the \var{choose*} constants) will
indicate this.

Give the tool a chance to use the processor. You should call this
method regularly.

Abort an outstanding asynchronous \var{Open} or \var{Listen}.

Reset a connection. Exact meaning depends on the tool.

Send a break. Whether this means anything, what it means and
interpretation of the \var{length} parameter depend on the tool in