showConnections             package:base             R Documentation

_D_i_s_p_l_a_y _C_o_n_n_e_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Display aspects of connections.

_U_s_a_g_e:

     showConnections(all = FALSE)
     getConnection(what)
     closeAllConnections()

     stdin()
     stdout()
     stderr()

_A_r_g_u_m_e_n_t_s:

     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'.

_D_e_t_a_i_l_s:

     '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' (and in some circumstances the output from
     'stdout()' can be split: see the help page).

     The encoding for 'stdin()' when redirected can be set by the
     command-line flag '--encoding'.

     '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.

     'closeAllConnections' closes (and destroys) all user connections,
     restoring all 'sink' diversions as it does so.

_V_a_l_u_e:

     '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'.

_N_o_t_e:

     'stdin()' refers to the 'console' and not to the C-level 'stdin'
     of the process.  The distinction matters in GUI consoles (which
     may not have an active 'stdin', and if they do it may not be
     connected to console input), and also in embedded applications. If
     you want access to the C-level file stream 'stdin', use
     'file("stdin")'.

     When R is reading a script from a file, the _file_ is the
     'console': this is traditional usage to allow in-line data (see
     'An Introduction to R' for an example).

_S_e_e _A_l_s_o:

     'connections'

_E_x_a_m_p_l_e_s:

     showConnections(all = TRUE)

     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"     
     ## Not run: close(getConnection(3))

     showConnections()

