Flashnux

GNU/Linux man pages

Livre :
Expressions régulières,
Syntaxe et mise en oeuvre :

ISBN : 978-2-7460-9712-4
EAN : 9782746097124
(Editions ENI)

GNU/Linux

CentOS 3.1

NAL_SELECTOR_new(2)


NAL_SELECTOR_NEW

NAL_SELECTOR_NEW

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
NOTES
SEE ALSO
AUTHOR

NAME

NAL_SELECTOR_new, NAL_SELECTOR_free, NAL_SELECTOR_add_conn, NAL_SELECTOR_del_conn, NAL_SELECTOR_add_conn_ex, NAL_SELECTOR_add_listener, NAL_SELECTOR_del_listener, NAL_SELECTOR_select − libnal selector functions

SYNOPSIS

 #include <libnal/nal.h>

 NAL_SELECTOR *NAL_SELECTOR_new(void);
 void NAL_SELECTOR_free(NAL_SELECTOR *a);
 void NAL_SELECTOR_add_conn(NAL_SELECTOR *sel, const NAL_CONNECTION *conn);
 void NAL_SELECTOR_del_conn(NAL_SELECTOR *sel, const NAL_CONNECTION *conn);
 void NAL_SELECTOR_add_conn_ex(NAL_SELECTOR *sel, const NAL_CONNECTION *conn,
                              unsigned int flags);
 void NAL_SELECTOR_add_listener(NAL_SELECTOR *sel, const NAL_LISTENER *list);
 void NAL_SELECTOR_del_listener(NAL_SELECTOR *sel, const NAL_LISTENER *list);
 int NAL_SELECTOR_select(NAL_SELECTOR *sel, unsigned long usec_timeout,
                         int use_timeout);

DESCRIPTION

NAL_SELECTOR_new() allocates and initialises a new NAL_SELECTOR object.

NAL_SELECTOR_free() destroys a NAL_SELECTOR object.

NAL_SELECTOR_add_conn(), NAL_SELECTOR_del_conn() and NAL_SELECTOR_add_conn_ex() handle adding conn to (or removing it from) the selector sel. See " NOTES ".

NAL_SELECTOR_add_listener() and NAL_SELECTOR_del_listener() add or remove the listener list to/from the selector sel. See " NOTES ".

NAL_SELECTOR_select() blocks until the selector sel receives notification of network events for which it has registered interest. This function blocks indefinitely until receipt of a network event, interruption by the system, or if use_timeout is non−zero, then the function will break if more than usec_timeout microseconds have passed. See " NOTES ".

RETURN VALUES

NAL_SELECTOR_new() returns a valid NAL_SELECTOR object on success, NULL otherwise.

NAL_SELECTOR_free(), NAL_SELECTOR_add_conn(), NAL_SELECTOR_del_conn(), NAL_SELECTOR_add_conn_ex(), NAL_SELECTOR_add_listener(), and NAL_SELECTOR_del_listener() has no return value.

NAL_SELECTOR_select() returns negative for an error, otherwise it returns the number of connections and/or listeners that the selector has detected have network events waiting (which can be zero).

NOTES

The interaction of selectors and connections is as follows. When a connection is added to selector with NAL_SELECTOR_add_conn() the selector will; (a) always register the connection for exception events, (b) register the connection for readability events only if the connection’s read buffer is not full, and (c) register the connection for sendability events only if the connection’s send buffer is not empty. NAL_SELECTOR_del_conn() unregisters a connection from any events it had already been registered. NAL_SELECTOR_add_conn_ex() allows the caller to restrict the behaviour of NAL_SELECTOR_add_conn() according to the following arguments for the flags argument;

 #define NAL_SELECT_FLAG_READ (unsigned int)0x0001
 #define NAL_SELECT_FLAG_SEND (unsigned int)0x0002
 #define NAL_SELECT_FLAG_RW   (NAL_SELECT_FLAG_READ ⎪ NAL_SELECT_FLAG_SEND)

NAL_SELECTOR_add_conn() is equivalent to NAL_SELECTOR_add_conn_ex() with flags set to NAL_SELECT_FLAG_RW .

The interaction of selectors and listeners is easier still. When a listener is added to a selector with NAL_SELECTOR_add_listener() the selector will register the listener for exception and readability events. A readability event on a listener indicates a connection request. NAL_SELECTOR_del_listener() equally unregisters the listener from any events it had already been registered.

The behaviour of NAL_SELECTOR_select() is what one would normally expect from a system select(2) function. On error, the return value is negative. Otherwise the return value is the number of connection and/or listener objects that have network events waiting for them. A return value of zero is possible if the function breaks before any network events have arrived, eg. if use_timeout was specified, or if a non-blocked signal arrived. In such cases, subsequent calls to NAL_CONNECTION_io() and NAL_LISTENER_accept() will trivially return without performing any actions as the selector has no events registered for processing. As such, if NAL_SELECTOR_select() returns zero, it is generally advised to add the connections and listeners back to the selector object and call NAL_SELECTOR_select() again.

As with other libnal functions, ’errno’ is not touched so that any errors in the system’s underlying implementations can be investigated directly by the calling application.

SEE ALSO

NAL_ADDRESS_new(2) − Functions for the NAL_ADDRESS type.

NAL_CONNECTION_new(2) − Functions for the NAL_CONNECTION type.

NAL_LISTENER_new(2) − Functions for the NAL_LISTENER type.

NAL_BUFFER_new(2) − Functions for the NAL_BUFFER type.

distcache(8) − Overview of the distcache architecture.

http://www.distcache.org/ − Distcache home page.

AUTHOR

This toolkit was designed and implemented by Geoff Thorpe for Cryptographic Appliances Incorporated. Since the project was released into open source, it has a home page and a project environment where development, mailing lists, and releases are organised. For problems with the software or this man page please check for new releases at the project web-site below, mail the users mailing list described there, or contact the author at geoff@geoffthorpe.net.

Home Page: http://www.distcache.org



NAL_SELECTOR_new(2)