[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  showConnections: Display Connections

##  Description

Display aspects of [ connections
](/link/connections?package=base&version=3.6.2) .

##  Usage

    
    
    showConnections(all = FALSE)
    getConnection(what)
    closeAllConnections()
    
    stdin()
    stdout()
    stderr()
    nullfile()
    
    isatty(con)

##  Arguments

all

logical: if true all connections, including closed ones and the standard ones
are displayed. If false only open user-created connections are included.

what

integer: a row number of the table given by ` showConnections ` .

con

a connection.

##  Value

` stdin() ` , ` stdout() ` and ` stderr() ` return connection objects.

` showConnections ` returns a character matrix of information with a row for
each connection, by default only for open non-standard connections.

` getConnection ` returns a connection object, or ` NULL ` .

##  Details

` stdin() ` , ` stdout() ` and ` stderr() ` are standard connections
corresponding to input, output and error on the console respectively (and not
necessarily to file streams). They are text-mode connections of class `
"terminal" ` which cannot be opened or closed, and are read-only, write-only
and write-only respectively. The ` stdout() ` and ` stderr() ` connections can
be re-directed by ` [ sink ](/link/sink?package=base&version=3.6.2) ` (and in
some circumstances the output from ` stdout() ` can be split: see the help
page).

The encoding for ` [ stdin ](/link/stdin?package=base&version=3.6.2) () ` when
redirected can be set by the command-line flag  \--encoding  .

` nullfile() ` returns filename of the null device ( ` "/dev/null" ` on Unix,
` "nul:" ` on Windows).

` showConnections ` returns a matrix of information. If a connection object
has been lost or forgotten, ` getConnection ` will take a row number from the
table and return a connection object for that connection, which can be used to
close the connection, for example. However, if there is no  R  level object
referring to the connection it will be closed automatically at the next
garbage collection (except for ` [ gzcon
](/link/gzcon?package=base&version=3.6.2) ` connections).

` closeAllConnections ` closes (and destroys) all user connections, restoring
all ` [ sink ](/link/sink?package=base&version=3.6.2) ` diversions as it does
so.

` isatty ` returns true if the connection is one of the class ` "terminal" `
connections and it is apparently connected to a terminal, otherwise false.
This may not be reliable in embedded applications, including GUI consoles.

##  See Also

` [ connections ](/link/connections?package=base&version=3.6.2) `

##  Examples

[ Run this code
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2FshowConnections&utm_source=r-docs&utm_medium=docs&utm_term=showConnections&utm_content=run_example_in_workspace)

    
    
    # NOT RUN {
    showConnections(all = TRUE)
    # }
    # NOT RUN {
    textConnection(letters)
    # oops, I forgot to record that one
    showConnections()
    #  class     description      mode text   isopen   can read can write
    #3 "letters" "textConnection" "r"  "text" "opened" "yes"    "no"
    mycon <- getConnection(3)
    # }
    # NOT RUN {
    c(isatty(stdin()), isatty(stdout()), isatty(stderr()))
    # }
    

Run the code above in your browser using  [ DataCamp Workspace
](https://app.datacamp.com/workspace/preview?_tag=rdocs&rdocsPath=packages%2Fbase%2Fversions%2F3.6.2%2Ftopics%2FshowConnections&utm_source=r-docs&utm_medium=docs&utm_term=showConnections&utm_content=run_example_in_workspace)

Powered by  [ DataCamp ](https://www.datacamp.com/)