%read_ssl() function

The %read_ssl() function reads the number of bytes designated in size into var, from the Secure connection specified by ssl_fd descriptor. This descriptor is returned by a previous call to %accept_ssl() or %connect_ssl.

Note: To use this function, the OpenSSL libraries must be installed.

The %read_ssl() function reads the number of bytes designated in size into var, from the Secure connection specified by ssl_fd descriptor. This descriptor is returned by a previous call to %accept_ssl() or %connect_ssl.

Syntax

n = %read_ssl(ssl_fd, var, size)

Parameter(s)

ssl_fd File descriptor of the secure connection.

Description

A string of a size at least equal to size must have been assigned to var before the call by either an explicit assignment (for example, buffer=space(1000)) or by the char reserve statement, or else the data is truncated.

This function returns the number of bytes actually read. If the bytes returned are less than size, the content of the trailing string is undefined, as is normal in C. No data translation occurs. If the data read in var contains segment marks (x’ff’), results are unpredictable.

In the case of an error, the return code is a negative value. The table below lists all of the error return codes:

-1 SSL_read error, system(0) function is set to the value of ssl_get_error.
-2 OpenSSL is not installed.

item=’’
char buffer[10000] ;* reserve buffer space
 
loop while true do
n=%read_ssl(ssl_fd, buffer, 10000)
   if n < 0 then
      print "Error ":system(0)
      stop
   end else
      if n<10000 then
         * The whole file has been read.
         Example(s)item=item:buffer[1,n]
         convert char(10) to char(254) in item
         write item on itemname
         stop
         end else
      * Some more to read
      item=item:buffer
   end
end
repeat