\HeaderA{rawConnection}{Raw Connections}{rawConnection}
\aliasA{rawConnectionValue}{rawConnection}{rawConnectionValue}
\keyword{file}{rawConnection}
\keyword{connection}{rawConnection}
\begin{Description}\relax
Input and output raw connections.
\end{Description}
\begin{Usage}
\begin{verbatim}
rawConnection(object, open = "r")

rawConnectionValue(con)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] character or raw vector.  A description of the connection. 
For an input this is an \R{} raw vector object, and for an output
connection the name for the connection.

\item[\code{open}] character.  Any of the standard connection open modes.
\item[\code{con}] An output raw connection.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
An input raw connection is opened and the raw vector is copied
at the time the connection object is created, and \code{close}
destroys the copy.

An output raw connection is opened and creates an \R{} raw vector
internally.  The raw vector can be retrieved \emph{via} 
\code{rawConnectionValue}.

If a connection is open for both input and output the initial raw
vector supplied is copied when the connections is open
\end{Details}
\begin{Value}
For \code{rawConnection}, a connection object of class
\code{"rawConnection"} which inherits from class \code{"connection"}.

For \code{rawConnectionValue}, a raw vector.
\end{Value}
\begin{Note}\relax
As output raw connections keep the internal raw vector up to date
call-by-call, they are relatively expensive to use (although
over-allocation is used), and it may be better to use an anonymous
\code{\LinkA{file}{file}()} connection to collect output.

On (rare) platforms where \code{vsnprintf} does not return the needed length
of output there is a 100,000 character limit on the length of line for
output connections: longer lines will be truncated with a warning.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{connections}{connections}}, \code{\LinkA{showConnections}{showConnections}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
zz <- rawConnection(raw(0), "r+") # start with empty raw vector
writeBin(LETTERS, zz)
seek(zz, 0)
readLines(zz) # raw vector has embedded nuls
seek(zz, 0)
writeBin(letters[1:3], zz)
rawConnectionValue(zz)
close(zz)
\end{ExampleCode}
\end{Examples}

