Sun Java System Web Server 7.0 Update 3 NSAPI Developer's Guide

read() Function

The read filter method is called when input data is required. Filters that modify or consume incoming data should implement the read filter method.

Upon receiving control, a read implementation should fill buf with up to amount bytes of input data. This data can be obtained by calling the net_read() function, as shown in the example below.


int read(FilterLayer *layer, void *buf, int amount, int timeout);

Return Values

The number of bytes placed in buf on success. 0 if no data is available, or a negative value if an error occurs.


FilterLayer *layer is the filter layer in which the filter is installed.

void *buf is the buffer in which data should be placed.

int amount is the maximum number of bytes that should be placed in the buffer.

int timeout is the number of seconds to allow the read operation to return. The purpose of timeout is to limit the amount of time devoted to waiting until some data arrives, not to return because not enough bytes were read in the given time.


int myfilter_read(FilterLayer *layer, void *buf, int amount, int timeout)
    return net_read(layer->lower, buf, amount, timeout);

See Also

net_read() Function, filter_create() Function