forsyth20121205-174063a80cc13 years agoHistory
68 lines · 1.8 KB · Text
RawDownload
.TH KEYRING-GETMSG 2.SH NAMEkeyring: getmsg, sendmsg, senderrmsg \- send and receive messages on undelimited streams.SH SYNOPSIS.EXinclude "keyring.m";keyring := load Keyring Keyring->PATH; getmsg:  fn(fd: ref Sys->FD): array of byte;sendmsg: fn(fd: ref Sys->FD, buf: array of byte, n: int): int;senderrmsg: fn(fd: ref Sys->FD, s: string): int;.EE.SH DESCRIPTIONThese functions allow arbitrary data, packed into arrays of bytes, to be exchangedon network connections using connection-oriented transport protocols that do not preserverecord boundaries (eg, TCP/IP without.IR ssl (3)).They are used to implement various authentication protocols, including.IR auth (6),as implemented by.IR keyring-auth (2)..PPEach data message is transmitted with a five-byte header containing a four-character zero-padded decimal count.I nterminated by a newline, followed by.I nbytes of message data.An error message has a similar structure, except that the first characterof the count is replaced by an exclamation mark.RB ( ! );the message data followingcontains the diagnostic string in its UTF-8 encoding (see.IR utf (6))..PP.B Getmsgreads the next message from.I fdand returns its data content..PP.B Sendmsgsends the first.I nbytes of.I bufas a message on.IR fd ,and returns.IR n ..PP.B Senderrmsgsends the error message.IR s ..SH SOURCE.B /libinterp/keyring.c.SH DIAGNOSTICS.B Sendmsgand.B senderrmsgreturn -1 if there was an error writing to.IR fd ;they set the system error string..B Getmsgreturns nil if there was an error reading from.IR fd ;it sets the system error string to reflect the cause.It also returns nilif an error message was received instead of a data message;the system error string will contain the error message's diagnostic.