libevent  2.2.1
Event notification library
Macros | Functions
bufferevent_compat.h File Reference

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 buffereventbufferevent_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...
 

Detailed Description

Deprecated versions of the functions in bufferevent.h: provided only for backwards compatibility.

Function Documentation

◆ bufferevent_new()

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_set_callbacks 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.

Deprecated:
This function is deprecated because it uses the current event base, and as such can be error prone for multithreaded programs. Use bufferevent_socket_new() instead.
Parameters
fdthe file descriptor from which data is read and written to. This file descriptor is not allowed to be a pipe(2).
readcbcallback to invoke when there is data to be read, or NULL if no callback is desired
writecbcallback to invoke when the file descriptor is ready for writing, or NULL if no callback is desired
errorcbcallback to invoke when there is an error on the file descriptor
cbargan argument that will be supplied to each of the callbacks (readcb, writecb, and errorcb)
Returns
a pointer to a newly allocated bufferevent struct, or NULL if an error occurred
See also
bufferevent_base_set(), bufferevent_free()

◆ bufferevent_settimeout()

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.

Deprecated:
Use bufferevent_set_timeouts instead.
Parameters
bufevthe bufferevent to be modified
timeout_readthe read timeout
timeout_writethe write timeout