[Top] [Prev] [Next] [Bottom]


[Contents] [Index]

getstring, putstring, getbytearray, putbytearray, puterror- delimited I/O

include "keyring.m"
keyring:= load Keyring Keyring->PATH;
getstring:   fn(fd: ref Sys->FD)  : (string, string);
putstring:   fn(fd: ref Sys->FD, s: string): int;
getbytearray:fn(fd: ref Sys->FD)  : (array of byte, 
string);
putbytearray: fn(fd: ref Sys->FD,a: array of byte, n: int):
                                                   int;
puterror:     fn(fd: ref Sys->FD,    s: string): int;

Description

This collection of routines provides delimited I/O for strings, byte arrays and error strings over arbitrary networks.

getstring (fd)

getstring:  fn(fd: ref Sys->FD) : (string, string);
## returns (nil, error message) on error.
The getstring function reads a text string from the file descriptor supplied as its argument. The return value is a tuple of the form (result, error). If successful, the error string is nil.

putstring (fd, s)

putstring:  fn(fd: ref Sys->FD, s: string): int;
## returns number of bytes written; -1 on error.
The putstring function writes the string supplied as its second argument to the file descriptor supplied as its first argument. It returns the number of bytes written to the network or -1 if an error occurred. Messages sent by putstring are truncated to 4096 bytes in length.

getbytearray (fd)

getbytearray:  fn(fd: ref Sys->FD) : 
(array of byte, string);
## returns (nil, error message) on error.
The getbytearray function reads an array of bytes from the file descriptor supplied as its argument and returns a tuple of the form (result, error). If successful the error string is nil.

putbytearray (fd, arr, n)

putbytearray: fn(fd: ref Sys->FD,a: array of byte, 
n: int) : int;
## returns number of bytes written; -1 on error.
The putbytearray function writes an array of bytes supplied as its second argument to the file descriptor supplied as its first argument. It returns the number of bytes written to the network or -1 if an error occurred. Messages sent by putbytearray are truncated to 4096 bytes in length.

puterror (fd, s)

puterror:     fn(fd: ref Sys->FD, s: string): int;
## returns number of bytes written; -1 on error.
The puterror function writes an error string supplied as its second argument to the file descriptor supplied as its first argument. This function can be used in place of putstring or putbytearray to cause the corresponding getstring or getbytearray to fail, yielding the error string. The error string may not be longer than ERRLEN bytes.



[Top] [Prev] [Next] [Bottom]

infernosupport@lucent.com
Copyright © 1997, Lucent Technologies, Inc.. All rights reserved.