rawConnection              package:base              R Documentation

_R_a_w _C_o_n_n_e_c_t_i_o_n_s

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

     Input and output raw connections.

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

     rawConnection(object, open = "r")

     rawConnectionValue(con)

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

  object: character or raw vector.  A description of the connection. 
          For an input this is an R raw vector object, and for an
          output connection the name for the connection. 

    open: character.  Any of the standard connection open modes.

     con: An output raw connection.

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

     An input raw connection is opened and the raw vector is copied at
     the time the connection object is created, and 'close' destroys
     the copy.

     An output raw connection is opened and creates an R raw vector
     internally.  The raw vector can be retrieved _via_ 
     'rawConnectionValue'.

     If a connection is open for both input and output the initial raw
     vector supplied is copied when the connections is open

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

     For 'rawConnection', a connection object of class
     '"rawConnection"' which inherits from class '"connection"'.

     For 'rawConnectionValue', a raw vector.

_N_o_t_e:

     As output raw connections keep the internal raw vector up to date
     call-by-call, they are relatively expensive to use (although
     over-allocation is used), and it may be better to use an anonymous
     'file()' connection to collect output.

     On (rare) platforms where 'vsnprintf' does not return the needed
     length of output there is a 100,000 character limit on the length
     of line for output connections: longer lines will be truncated
     with a warning.

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

     'connections', 'showConnections'.

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

     zz <- rawConnection(raw(0), "r+") # start with empty raw vector
     writeBin(LETTERS, zz)
     seek(zz, 0)
     readLines(zz) # raw vector has embedded nuls
     seek(zz, 0)
     writeBin(letters[1:3], zz)
     rawConnectionValue(zz)
     close(zz)

