The R connection internals are conceptually similar to the Linux device driver API. Linux device drivers register C functions with the Linux kernel to be called when user programs request to read, write, map memory, or otherwise alter a device that the driver controls. Writing the code for a Linux device driver involves creating a kernel module, a concept similar to R's package mechanism.
In a fashion similar to Linux device drivers, R connections register C functions to be called when the R user requests to create, read, write, or modify a connection. Each type of R connection performs a specialized task, yet has a common interface with the R program. This ensures that generic functions like
seek work on all types of connections.
Every R connection is associated with a structure that contains all the symbols necessary to identify the connection, perform I/O operations, character re-encoding, finalization, and storage of connection-specific data. R level functions, such as
writeChar ultimately call C functions that access the symbols in this structure to perform their task.