forsyth20121205-174063a80cc13 years agoHistory
90 lines · 2.0 KB · Text
RawDownload
.TH KEYRING-GETSTRING 2.SH NAMEkeyring: getstring, putstring, getbytearray, putbytearray, puterror \- exchange data on delimited streams.SH SYNOPSIS.EXinclude "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;.EE.SH DESCRIPTIONThese functions provideI/O for strings, byte arrays and error strings over network connections thatprovide a record structure for communication (as provided for arbitrarynetworks by.IR ssl (3))..PP.B Putstringwrites string.I sto.IR fd.It returns the number of bytes written, or -1 if an error occurred.Messages written by.B putstringare truncated to 4096 bytes..PP.B Getstringreads a string as written by.B putstringfrom.IR fdand returns a tuple.RI ( result , error ).If successful, the errorstring is nil..PP.B Putbytearraywrites the array of bytes.I ato.IR fd .It returns the number of bytes written, or -1 if an error occurred.Messages written by.B putbytearrayare truncated to 4096 bytes..PP.B Getbytearrayreads an array of bytes as written by.B putbytearrayfrom.IR fdand returns a tuple of the form.RI ( result , error ).If successful, the error string is nil..PP.B Puterrorwrites an error string.I sto.IR fd .It can be used in place of.B putstringor.B putbytearrayto cause a corresponding.B getstringor.B getbytearrayto fail(in the receiving process),forcing them to return the error string.IR s .It may not be longer than.BR Sys->ERRMAXbytes..SH SOURCE.B /libinterp/keyring.c.SH DIAGNOSTICSThe output functions return an.B intwhich is -1 if there was an I/O error,and a non-negative value otherwise.The input functionsreturn a tuple that includes a string indicating the cause of theerror, as the second element of the tuple.