1995-03-17 12:07:09 -04:00
|
|
|
\section{Built-in Module \sectcode{mactcp}}
|
1997-07-17 13:34:52 -03:00
|
|
|
\label{module-mactcp}
|
1995-03-01 10:54:30 -04:00
|
|
|
\bimodindex{mactcp}
|
1995-03-17 12:07:09 -04:00
|
|
|
|
1998-02-13 02:58:54 -04:00
|
|
|
\setindexsubitem{(in module mactcp)}
|
1995-03-01 10:54:30 -04:00
|
|
|
|
|
|
|
This module provides an interface to the Macintosh TCP/IP driver
|
1995-03-13 06:03:32 -04:00
|
|
|
MacTCP\@. There is an accompanying module \code{macdnr} which provides an
|
1995-03-01 10:54:30 -04:00
|
|
|
interface to the name-server (allowing you to translate hostnames to
|
1996-07-20 23:20:58 -03:00
|
|
|
ip-addresses), a module \code{MACTCPconst} which has symbolic names for
|
|
|
|
constants constants used by MacTCP. Since the builtin module
|
|
|
|
\code{socket} is also available on the mac it is usually easier to use
|
|
|
|
sockets in stead of the mac-specific MacTCP API.
|
1995-03-01 10:54:30 -04:00
|
|
|
|
|
|
|
A complete description of the MacTCP interface can be found in the
|
|
|
|
Apple MacTCP API documentation.
|
|
|
|
|
|
|
|
\begin{funcdesc}{MTU}{}
|
|
|
|
Return the Maximum Transmit Unit (the packet size) of the network
|
|
|
|
interface.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{IPAddr}{}
|
|
|
|
Return the 32-bit integer IP address of the network interface.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{NetMask}{}
|
|
|
|
Return the 32-bit integer network mask of the interface.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{TCPCreate}{size}
|
1995-03-13 06:03:32 -04:00
|
|
|
Create a TCP Stream object. \var{size} is the size of the receive
|
1995-03-01 10:54:30 -04:00
|
|
|
buffer, \code{4096} is suggested by various sources.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{UDPCreate}{size, port}
|
1995-03-13 06:03:32 -04:00
|
|
|
Create a UDP stream object. \var{size} is the size of the receive
|
1995-03-01 10:54:30 -04:00
|
|
|
buffer (and, hence, the size of the biggest datagram you can receive
|
1995-03-13 06:03:32 -04:00
|
|
|
on this port). \var{port} is the UDP port number you want to receive
|
1995-03-01 10:54:30 -04:00
|
|
|
datagrams on, a value of zero will make MacTCP select a free port.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
1995-03-17 12:07:09 -04:00
|
|
|
\subsection{TCP Stream Objects}
|
|
|
|
|
1998-02-13 02:58:54 -04:00
|
|
|
\setindexsubitem{(TCP stream attribute)}
|
1995-03-01 10:54:30 -04:00
|
|
|
|
|
|
|
\begin{datadesc}{asr}
|
1995-03-13 06:03:32 -04:00
|
|
|
When set to a value different than \code{None} this should point to a
|
|
|
|
function with two integer parameters:\ an event code and a detail. This
|
1995-03-01 10:54:30 -04:00
|
|
|
function will be called upon network-generated events such as urgent
|
|
|
|
data arrival. In addition, it is called with eventcode
|
1995-03-13 06:03:32 -04:00
|
|
|
\code{MACTCP.PassiveOpenDone} when a \code{PassiveOpen} completes. This
|
|
|
|
is a Python addition to the MacTCP semantics.
|
|
|
|
It is safe to do further calls from the \code{asr}.
|
1995-03-01 10:54:30 -04:00
|
|
|
\end{datadesc}
|
|
|
|
|
1998-02-13 02:58:54 -04:00
|
|
|
\setindexsubitem{(TCP stream method)}
|
1995-03-17 12:07:09 -04:00
|
|
|
|
1995-03-01 10:54:30 -04:00
|
|
|
\begin{funcdesc}{PassiveOpen}{port}
|
|
|
|
Wait for an incoming connection on TCP port \var{port} (zero makes the
|
1995-03-13 06:03:32 -04:00
|
|
|
system pick a free port). The call returns immediately, and you should
|
1995-03-01 10:54:30 -04:00
|
|
|
use \var{wait} to wait for completion. You should not issue any method
|
|
|
|
calls other than
|
1995-03-13 06:03:32 -04:00
|
|
|
\code{wait}, \code{isdone} or \code{GetSockName} before the call
|
1995-03-01 10:54:30 -04:00
|
|
|
completes.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{wait}{}
|
1995-03-13 06:03:32 -04:00
|
|
|
Wait for \code{PassiveOpen} to complete.
|
1995-03-01 10:54:30 -04:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{isdone}{}
|
1995-03-13 06:03:32 -04:00
|
|
|
Return 1 if a \code{PassiveOpen} has completed.
|
1995-03-01 10:54:30 -04:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{GetSockName}{}
|
|
|
|
Return the TCP address of this side of a connection as a 2-tuple
|
|
|
|
\code{(host, port)}, both integers.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{ActiveOpen}{lport\, host\, rport}
|
1995-03-13 06:03:32 -04:00
|
|
|
Open an outgoing connection to TCP address \code{(\var{host}, \var{rport})}. Use
|
1995-03-01 10:54:30 -04:00
|
|
|
local port \var{lport} (zero makes the system pick a free port). This
|
1995-03-13 06:03:32 -04:00
|
|
|
call blocks until the connection has been established.
|
1995-03-01 10:54:30 -04:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{Send}{buf\, push\, urgent}
|
|
|
|
Send data \var{buf} over the connection. \var{Push} and \var{urgent}
|
|
|
|
are flags as specified by the TCP standard.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{Rcv}{timeout}
|
|
|
|
Receive data. The call returns when \var{timeout} seconds have passed
|
|
|
|
or when (according to the MacTCP documentation) ``a reasonable amount
|
|
|
|
of data has been received''. The return value is a 3-tuple
|
1995-03-13 06:03:32 -04:00
|
|
|
\code{(\var{data}, \var{urgent}, \var{mark})}. If urgent data is outstanding \code{Rcv}
|
1995-03-01 10:54:30 -04:00
|
|
|
will always return that before looking at any normal data. The first
|
|
|
|
call returning urgent data will have the \var{urgent} flag set, the
|
|
|
|
last will have the \var{mark} flag set.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{Close}{}
|
|
|
|
Tell MacTCP that no more data will be transmitted on this
|
1995-03-13 06:03:32 -04:00
|
|
|
connection. The call returns when all data has been acknowledged by
|
1995-03-01 10:54:30 -04:00
|
|
|
the receiving side.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{Abort}{}
|
|
|
|
Forcibly close both sides of a connection, ignoring outstanding data.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{Status}{}
|
1995-03-17 12:07:09 -04:00
|
|
|
Return a TCP status object for this stream giving the current status
|
|
|
|
(see below).
|
1995-03-01 10:54:30 -04:00
|
|
|
\end{funcdesc}
|
|
|
|
|
1995-03-17 12:07:09 -04:00
|
|
|
\subsection{TCP Status Objects}
|
1995-03-01 10:54:30 -04:00
|
|
|
This object has no methods, only some members holding information on
|
|
|
|
the connection. A complete description of all fields in this objects
|
|
|
|
can be found in the Apple documentation. The most interesting ones are:
|
|
|
|
|
1998-02-13 02:58:54 -04:00
|
|
|
\setindexsubitem{(TCP status attribute)}
|
1995-03-17 12:07:09 -04:00
|
|
|
|
1995-03-01 10:54:30 -04:00
|
|
|
\begin{datadesc}{localHost}
|
|
|
|
\dataline{localPort}
|
|
|
|
\dataline{remoteHost}
|
|
|
|
\dataline{remotePort}
|
|
|
|
The integer IP-addresses and port numbers of both endpoints of the
|
|
|
|
connection.
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{sendWindow}
|
|
|
|
The current window size.
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{amtUnackedData}
|
|
|
|
The number of bytes sent but not yet acknowledged. \code{sendWindow -
|
|
|
|
amtUnackedData} is what you can pass to \code{Send} without blocking.
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{amtUnreadData}
|
1995-03-13 06:03:32 -04:00
|
|
|
The number of bytes received but not yet read (what you can \code{Recv}
|
1995-03-01 10:54:30 -04:00
|
|
|
without blocking).
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
|
|
|
|
|
1995-03-17 12:07:09 -04:00
|
|
|
\subsection{UDP Stream Objects}
|
1995-03-01 10:54:30 -04:00
|
|
|
Note that, unlike the name suggests, there is nothing stream-like
|
|
|
|
about UDP.
|
|
|
|
|
1998-02-13 02:58:54 -04:00
|
|
|
\setindexsubitem{(UDP stream attribute)}
|
1995-03-01 10:54:30 -04:00
|
|
|
|
|
|
|
\begin{datadesc}{asr}
|
|
|
|
The asynchronous service routine to be called on events such as
|
1995-03-13 06:03:32 -04:00
|
|
|
datagram arrival without outstanding \code{Read} call. The \code{asr} has a
|
1995-03-01 10:54:30 -04:00
|
|
|
single argument, the event code.
|
|
|
|
\end{datadesc}
|
|
|
|
|
|
|
|
\begin{datadesc}{port}
|
|
|
|
A read-only member giving the port number of this UDP stream.
|
|
|
|
\end{datadesc}
|
|
|
|
|
1998-02-13 02:58:54 -04:00
|
|
|
\setindexsubitem{(UDP stream method)}
|
1995-03-17 12:07:09 -04:00
|
|
|
|
1995-03-01 10:54:30 -04:00
|
|
|
\begin{funcdesc}{Read}{timeout}
|
1997-11-24 21:00:40 -04:00
|
|
|
Read a datagram, waiting at most \var{timeout} seconds (-1 is
|
1995-03-17 12:07:09 -04:00
|
|
|
infinite). Return the data.
|
1995-03-01 10:54:30 -04:00
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{Write}{host\, port\, buf}
|
|
|
|
Send \var{buf} as a datagram to IP-address \var{host}, port
|
|
|
|
\var{port}.
|
|
|
|
\end{funcdesc}
|