Added an optional $timeout parameter to r\connect().