Next: Life Cycle, Previous: Components, Up: Specifics
A pointer (Rconnection
) to a struct Rconn
structure for each connection is stored in a static
declared, statically allocated array in src/main/connections.c
named Connections
. The size of the array is set at compile time by the NCONNECTIONS
macro, limiting the maximum number of connections in a single R session (currently 128). However, all struct Rconn
structures, and several other arrays used by connections are dynamically allocated when a connection is created. The first three connections referenced in the Connections
array are reserved for the special `terminal' connections with descriptions ‘stdin
’, ‘stdout
’, and ‘stderr
’. These connections may not be modified.
Several functions are available to operate on the Connections
array, including
int NextConnection(void)
Connections
array
int ConnIndex(Rconnection)
Rconnection
in the Connections
array
Rconnection getConnection(int)
Rconnection
pointer at the int
position of the Connections
array
Rconnection getConnection_no_err(int)
getConnection(int)
but will return NULL
rather than call generate an error.
void InitConnections(void)
stdin
’, ‘stdout
’, and ‘stderr
’ connections