Index: ossp-pkg/sa/sa.pod RCS File: /v/ossp/cvs/ossp-pkg/sa/sa.pod,v rcsdiff -q -kk '-r1.28' '-r1.29' -u '/v/ossp/cvs/ossp-pkg/sa/sa.pod,v' 2>/dev/null --- sa.pod 2002/10/25 17:36:08 1.28 +++ sa.pod 2002/10/25 18:10:43 1.29 @@ -158,24 +158,24 @@ =item B Each I/O function in B is aware of timeouts (set by -sa_timeout()), i.e., all I/O operations return C if the -timeout expired before the I/O operation was able to succeed. This -allows one to easily program less-blocking network services. B internally implements these timeouts either through the -C feature on more modern I implementations -or through traditional select(2). This way high performance is achieved -on modern platforms while the full functionality still is available on -older platforms. +sa_timeout(3)), i.e., all I/O operations return C if +the timeout expired before the I/O operation was able to succeed. +This allows one to easily program less-blocking network services. +B internally implements these timeouts either through the +C{C,C}C feature on more modern I +implementations or through traditional select(2). This way high +performance is achieved on modern platforms while the full functionality +still is available on older platforms. =item B If B is used for stream communication, internally all I/O operations can be performed through input and/or output buffers (set -by sa_buffer()) for achieving higher I/O performance by doing I/O +by sa_buffer(3)) for achieving higher I/O performance by doing I/O operations on larger aggregated messages and with less required system calls. Additionally if B is used for stream communication, for -convenience reasons line-oriented reading (sa_readln()) and formatted -writing (see sa_writef()) is provided, modelled after STDIO's fgets(3) +convenience reasons line-oriented reading (sa_readln(3)) and formatted +writing (see sa_writef(3)) is provided, modelled after STDIO's fgets(3) and fprintf(3). Both features fully leverage from the I/O buffering. =back @@ -217,26 +217,32 @@ =head1 FUNCTIONS B provides a bunch of API functions, all modelled after the -same prototype: "C CIC<(sa_>[C]C<_t *,> -...C<)>". This means every function returns C to indicate its -success (C) or failure (C) by returning a return code -(the corresponding describing text can be determined by passing this -return code to C). Each function name starts with the common -prefix C and receives a C (or C) object on which +same prototype: + +C BIC<(sa_>[C]C<_t *,> ...C<)> + +This means, every function returns C to indicate its success +(C) or failure (CI) by returning a return code (the +corresponding describing text can be determined by passing this return +code to sa_error(3)). Each function name starts with the common prefix +C and receives a C (or C) object handle on which it operates as its first argument. =head2 Address Object Operations +This API part provides operations for the creation and destruction of +address abstraction C. + =over 4 -=item sa_rc_t B(sa_addr_t **I); +=item CBC<(sa_addr_t **>IC<);> Create a socket address abstraction object. The object is stored in I on success. Example: C -=item sa_rc_t B(sa_addr_t *I); +=item CBC<(sa_addr_t *>IC<);> Destroy a socket address abstraction object. The object I is invalid after this call succeeded. @@ -247,9 +253,12 @@ =head2 Address Operations +This API part provides operations for working with the address +abstraction C. + =over 4 -=item sa_rc_t B(sa_addr_t *I, const char *I, ...); +=item CBC<(sa_addr_t *>IC<, const char *>IC<, ...);> Import an address into by converting from an URI specification to the corresponding address abstraction. @@ -263,17 +272,16 @@ in dotted decimal notation ("C<127.0.0.1>"), an IPv6 address in colon-separated (optionally abbreviated) hexadecimal notation ("C<::1>") or a to-be-resolved hostname ("C"). I has -to be either a decimal port in the range C<1>...C<65535> or a port -name ("C"). If I is specified as a name, it is resolved as -a TCP port by default. To force resolving a I name via a -particular protocol, I can be specified as either "C" or -"C". +to be either a decimal port in the range C<1>...C<65535> or a port name +("C"). If I is specified as a name, it is resolved as a TCP +port by default. To force resolving a I name via a particular +protocol, I can be specified as either "C" or "C". The result is stored in I on success. Example: C -=item sa_rc_t B(sa_addr_t *I, const struct sockaddr *I, socklen_t I); +=item CBC<(sa_addr_t *>IC<, const struct sockaddr *>IC<, socklen_t >IC<);> Import an address by converting from a traditional C object to the corresponding address abstraction. @@ -281,13 +289,13 @@ The accepted addresses for I are: C (C), C (C) and C (C). The I is the corresponding -C of the underlying structure. +C of the particular underyling structure. The result is stored in I on success. Example: C -=item sa_rc_t B(sa_addr_t *I, char **I); +=item CBC<(sa_addr_t *>IC<, char **>IC<);> Export an address by converting from the address abstraction to the corresponding URI specification. @@ -296,7 +304,7 @@ Domain> addresses and "CIC<:>I" for I addresses. Notice that I and I are returned in numerical (unresolved) way. Additionally, because usually one cannot map -bi-directionally between TCP or UDP port names and the numerical value, +bidirectionally between TCP or UDP port names and the numerical value, there is no distinction between TCP and UDP here. The result is stored in I on success. @@ -304,21 +312,21 @@ Example: C -=item sa_rc_t B(sa_addr_t *I, struct sockaddr **I, socklen_t *I); +=item CBC<(sa_addr_t *>IC<, struct sockaddr **>IC<, socklen_t *>IC<);> Export an address by converting from the address abstraction to the corresponding traditional C object. -The result is one of the following underlying address structures: C (C), C (C) and C (C). +The result is one of the following particular underlying address +structures: C (C), C +(C) and C (C). The result is stored in I and I on success. The caller has to free(3) the I buffer later. Example: C -=item sa_rc_t B(sa_addr_t *I, sa_addr_t *I, size_t I); +=item CBC<(sa_addr_t *>IC<, sa_addr_t *>IC<, size_t >IC<);> Match two address abstractions up to a specified prefix. @@ -337,7 +345,7 @@ This especially can be used to implement Access Control Lists (ACL) without having to fiddle around with the underlying representation. -For this make I the to be checked address and I plus +For this, make I the to be checked address and I plus I the ACL pattern as shown in the following example. Example: @@ -367,16 +375,19 @@ =head2 Socket Object Operations +This API part provides operations for the creation and destruction of +socket abstraction C. + =over 4 -=item sa_rc_t B(sa_t **I); +=item CBC<(sa_t **>IC<);> Create a socket abstraction object. The object is stored in I on success. Example: C -=item sa_rc_t B(sa_t *I); +=item CBC<(sa_t *>IC<);> Destroy a socket abstraction object. The object I is invalid after this call succeeded. @@ -384,12 +395,15 @@ Example: C =back - + =head2 Socket Parameter Operations +This API part provides operations for parameterizing the socket +abstraction C. + =over 4 -=item sa_rc_t B(sa_t *I, sa_type_t I); +=item CBC<(sa_t *>IC<, sa_type_t >IC<);> Assign a particular communication protocol type to the socket abstraction object. @@ -406,39 +420,40 @@ Example: C -=item sa_rc_t B(sa_t *I, sa_timeout_t I, long I, long I); +=item CBC<(sa_t *>IC<, sa_timeout_t >IC<, long >IC<, long >IC<);> -Assign one or more communication timeouts to the socket abstraction object. +Assign one or more communication timeouts to the socket abstraction +object. Possible values for I are: C (affecting -sa_accept()), C (affecting sa_connect()), -C (affecting sa_read(), sa_readln() and sa_recv()) -and C (affecting sa_write(), sa_writef() and -sa_send()). Additionally you can set all four timeouts at once by using +sa_accept(3)), C (affecting sa_connect(3)), +C (affecting sa_read(3), sa_readln(3) and sa_recv(3)) +and C (affecting sa_write(3), sa_writef(3) and +sa_send(3)). Additionally you can set all four timeouts at once by using C. The default is that no communication timeouts are used which is equal to I=C<0>/I=C<0>. Example: C -=item sa_rc_t B(sa_t *I, sa_buffer_t I, size_t I); +=item CBC<(sa_t *>IC<, sa_buffer_t >IC<, size_t >IC<);> Assign I/O communication buffers to the socket abstraction object. -Possible values for I are: C (affecting sa_read() -and sa_readln()) and C (affecting sa_write() and -sa_writef()). The default is that no communication buffers are -used which is equal to I=C<0>. +Possible values for I are: C (affecting sa_read(3) +and sa_readln(3)) and C (affecting sa_write(3) and +sa_writef(3)). The default is that no communication buffers are used +which is equal to I=C<0>. Example: C -=item sa_rc_t B(sa_t *I, sa_option_t I, ...); +=item CBC<(sa_t *>IC<, sa_option_t >IC<, ...);> Adjust various options of the socket abstraction object. -The adjusted option is controlled by I. The number and type of -the expected following argument(s) are dependent on the particular -option. Currently the following options are implemented (option arguments -in parenthesis): +The adjusted option is controlled by I. The number and type of the +expected following argument(s) are dependent on the particular option. +Currently the following options are implemented (option arguments in +parenthesis): C (C I) for enabling (I=C<1>) or disabling (I == C<0>) Nagle's Algorithm (see RFC898). @@ -451,11 +466,11 @@ C (C I) for enabling (I == C<1>) or disabling (I == C<0>) the reusability of the address on -binding (see C of setsockopt(2)). +binding via sa_bind(3) (see C of setsockopt(2)). C (C I) for enabling (I == C<1>) or disabling (I == C<0>) the reusability of the port on binding -(see C of setsockopt(2)). +via sa_bind(3) (see C of setsockopt(2)). C (C I) for enabling (I == C<1>) or disabling (I == C<0>) non-blocking I/O mode (see C @@ -463,9 +478,10 @@ Example: C -=item sa_rc_t B(sa_t *I, sa_syscall_t I, void (*I)(), void *I); +=item CBC<(sa_t *>IC<, sa_syscall_t >IC<, void (*>IC<)(), void *>IC<);> -Divert I/O communication related system calls to user supplied callback functions. +Divert I/O communication related system calls to user supplied callback +functions. This allows you to override mostly all I/O related system calls B internally performs while communicating. This can be used to adapt @@ -484,25 +500,33 @@ Possible values for I are (expected prototypes behind I are given in parenthesis): -C: "C", see connect(2). +C: "C", see connect(2). -C: "C", see accept(2). +C: "C", see accept(2). -C: "C", see select(2). +C: "C", see select(2). -C: "C", see read(2). +C: "C", see +read(2). -C: "C", see write(2). +C: "C", see write(2). -C: "C", see recvfrom(2). +C: "C", see recvfrom(2). -C: "C", see sendto(2). +C: "C", see sendto(2). Example: FILE *trace_fp = ...; - ssize_t trace_read(void *ctx, int fd, void *buf, size_t len) + ssize_t + trace_read(void *ctx, int fd, void *buf, size_t len) { FILE *fp = (FILE *)ctx; ssize_t rv; @@ -510,7 +534,8 @@ rv = read(fd, buf, len); errno_saved = errno; - fprintf(fp, "read(%d, %lx, %d) = %d\n", fd, (long)buf, len, rv); + fprintf(fp, "read(%d, %lx, %d) = %d\n", + fd, (long)buf, len, rv); errno = errno_saved; return rv; } @@ -521,23 +546,26 @@ =head2 Socket Connection Operations +This API part provides operations for stream-oriented data communication +through the socket abstraction C. + =over 4 -=item sa_rc_t B(sa_t *I, sa_addr_t *I); +=item CBC<(sa_t *>IC<, sa_addr_t *>IC<);> Bind socket abstraction object to a local protocol address. This assigns the local protocol address I. When a socket is -created ) it exists in an address family space but has no protocol +created, it exists in an address family space but has no protocol address assigned. This call requests that I be used as the local address. For servers this is the address they later listen on (see -sa_listen()) for incoming connections, for clients this is the address -used for outgoing connections (see sa_connect()). Internally this +sa_listen(3)) for incoming connections, for clients this is the address +used for outgoing connections (see sa_connect(3)). Internally this directly maps to bind(2). Example: C -=item sa_rc_t B(sa_t *I, sa_addr_t *I); +=item CBC<(sa_t *>IC<, sa_addr_t *>IC<);> Initiate an outgoing connection on a socket abstraction object. @@ -551,7 +579,7 @@ Example: C -=item sa_rc_t B(sa_t *I, int I); +=item CBC<(sa_t *>IC<, int >IC<);> Listen for incoming connections on a socket abstraction object. @@ -562,7 +590,7 @@ Example: C -=item sa_rc_t B(sa_t *I, sa_addr_t **I, sa_t **I); +=item CBC<(sa_t *>IC<, sa_addr_t **>IC<, sa_t **>IC<);> Accept incoming connection on a socket abstraction object. @@ -583,7 +611,9 @@ ... } -=item sa_rc_t B(sa_t *I, sa_addr_t **I); +=item CBC<(sa_t *>IC<, sa_addr_t **>IC<);> + +FIXME =item sa_rc_t B(sa_t *I, sa_addr_t **I);