/*++ /* NAME /* clnt_stream 3 /* SUMMARY /* client endpoint maintenance /* SYNOPSIS /* #include <clnt_stream.h> /* /* typedef void (*CLNT_STREAM_HANDSHAKE_FN)(VSTREAM *) /* /* CLNT_STREAM *clnt_stream_create(class, service, timeout, ttl, /* handshake) /* const char *class; /* const char *service; /* int timeout; /* int ttl; /* CLNT_STREAM_HANDSHAKE_FN *handshake; /* /* VSTREAM *clnt_stream_access(clnt_stream) /* CLNT_STREAM *clnt_stream; /* /* void clnt_stream_recover(clnt_stream) /* CLNT_STREAM *clnt_stream; /* /* void clnt_stream_free(clnt_stream) /* CLNT_STREAM *clnt_stream; /* DESCRIPTION /* This module maintains local IPC client endpoints that automatically /* disconnect after a being idle for a configurable amount of time, /* that disconnect after a configurable time to live, /* and that transparently handle most server-initiated disconnects. /* Server disconnect is detected by read-selecting the client endpoint. /* The code assumes that the server has disconnected when the endpoint /* becomes readable. /* /* clnt_stream_create() instantiates a client endpoint. /* /* clnt_stream_access() returns an open stream to the service specified /* to clnt_stream_create(). The stream instance may change between calls. /* This function returns null when the handshake function returned an /* error. /* /* clnt_stream_recover() recovers from a server-initiated disconnect /* that happened in the middle of an I/O operation. /* /* clnt_stream_free() destroys of the specified client endpoint. /* /* Arguments: /* .IP class /* The service class, private or public. /* .IP service /* The service endpoint name. The name is limited to local IPC /* over sockets or equivalent. /* .IP timeout /* Idle time after which the client disconnects. /* .IP ttl /* Upper bound on the time that a connection is allowed to persist. /* .IP handshake /* Null pointer, or pointer to function that will be called /* at the start of a new connection and that returns 0 in case /* of success. /* DIAGNOSTICS /* Warnings: communication failure. Fatal error: mail system is down, /* out of memory. /* SEE ALSO /* mail_proto(3h) low-level mail component glue. /* LICENSE /* .ad /* .fi /* The Secure Mailer license must be distributed with this software. /* AUTHOR(S) /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Wietse Venema /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA
/*--*/
/* *CLNT_STREAMisanopaquestructure.Noneoftheaccessmethodscaneasily *beimplementedasamacro,andaccessisnotperformancecriticalanyway.
*/ struct CLNT_STREAM {
VSTREAM *vstream; /* buffered I/O */ int timeout; /* time before client disconnect */ int ttl; /* time before client disconnect */
CLNT_STREAM_HANDSHAKE_FN handshake; char *class; /* server class */ char *service; /* server name */
};
staticvoid clnt_stream_close(CLNT_STREAM *);
/* clnt_stream_event - server-initiated disconnect or client-side timeout */