libevent
2.2.1
Event notification library
|
Deprecated versions of the functions in bufferevent.h: provided only for backwards compatibility. More...
#include <event2/visibility.h>
Go to the source code of this file.
Macros | |
#define | EVBUFFER_EOF BEV_EVENT_EOF |
#define | EVBUFFER_ERROR BEV_EVENT_ERROR |
#define | EVBUFFER_INPUT(x) bufferevent_get_input(x) |
macro for getting access to the input buffer of a bufferevent | |
#define | EVBUFFER_OUTPUT(x) bufferevent_get_output(x) |
macro for getting access to the output buffer of a bufferevent | |
#define | EVBUFFER_READ BEV_EVENT_READING |
#define | EVBUFFER_TIMEOUT BEV_EVENT_TIMEOUT |
#define | EVBUFFER_WRITE BEV_EVENT_WRITING |
#define | evbuffercb bufferevent_data_cb |
#define | everrorcb bufferevent_event_cb |
Functions | |
EVENT2_EXPORT_SYMBOL struct bufferevent * | bufferevent_new (evutil_socket_t fd, evbuffercb readcb, evbuffercb writecb, everrorcb errorcb, void *cbarg) |
Create a new bufferevent for an fd. More... | |
EVENT2_EXPORT_SYMBOL void | bufferevent_settimeout (struct bufferevent *bufev, int timeout_read, int timeout_write) |
Set the read and write timeout for a buffered event. More... | |
Deprecated versions of the functions in bufferevent.h: provided only for backwards compatibility.
EVENT2_EXPORT_SYMBOL struct bufferevent* bufferevent_new | ( | evutil_socket_t | fd, |
evbuffercb | readcb, | ||
evbuffercb | writecb, | ||
everrorcb | errorcb, | ||
void * | cbarg | ||
) |
Create a new bufferevent for an fd.
This function is deprecated. Use bufferevent_socket_new() and bufferevent_setcb() instead.
Libevent provides an abstraction on top of the regular event callbacks. This abstraction is called a buffered event. A buffered event provides input and output buffers that get filled and drained automatically. The user of a buffered event no longer deals directly with the I/O, but instead is reading from input and writing to output buffers.
Once initialized, the bufferevent structure can be used repeatedly with bufferevent_enable() and bufferevent_disable().
When read enabled the bufferevent will try to read from the file descriptor and call the read callback. The write callback is executed whenever the output buffer is drained below the write low watermark, which is 0 by default.
If multiple bases are in use, bufferevent_base_set() must be called before enabling the bufferevent for the first time.
fd | the file descriptor from which data is read and written to. This file descriptor is not allowed to be a pipe(2). |
readcb | callback to invoke when there is data to be read, or NULL if no callback is desired |
writecb | callback to invoke when the file descriptor is ready for writing, or NULL if no callback is desired |
errorcb | callback to invoke when there is an error on the file descriptor |
cbarg | an argument that will be supplied to each of the callbacks (readcb, writecb, and errorcb) |
EVENT2_EXPORT_SYMBOL void bufferevent_settimeout | ( | struct bufferevent * | bufev, |
int | timeout_read, | ||
int | timeout_write | ||
) |
Set the read and write timeout for a buffered event.
bufev | the bufferevent to be modified |
timeout_read | the read timeout |
timeout_write | the write timeout |