Next: , Previous: Components, Up: Specifics


3.2 Important Symbols

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)
returns the next free pointer in the Connections array
int ConnIndex(Rconnection)
returns the index of Rconnection in the Connections array
Rconnection getConnection(int)
returns the Rconnection pointer at the int position of the Connections array
Rconnection getConnection_no_err(int)
same as getConnection(int) but will return NULL rather than call generate an error.
void InitConnections(void)
initializes ‘stdin’, ‘stdout’, and ‘stderr’ connections