Questions tagged [libevent]

libevent is an API for writing event driven systems. libevent is written in C and should compile on Linux, *BSD, Mac OS X, Solaris and Windows.

From the Homepage: Libevent

libevent is meant to replace the event loop found in event driven network servers. An application just needs to call event_dispatch() and then add or remove events dynamically without having to change the event loop.

Currently, libevent supports /dev/poll, kqueue(2), event ports, select(2), poll(2) and epoll(4). The internal event mechanism is completely independent of the exposed event API, and a simple update of libevent can provide new functionality without having to redesign the applications. As a result, Libevent allows for portable application development and provides the most scalable event notification mechanism available on an operating system. Libevent can also be used for multi-threaded applications; see Steven Grimm's explanation. Libevent should compile on Linux, *BSD, Mac OS X, Solaris and Windows.

368 questions
1
vote
2 answers

libevent during file deletion/modification

Is to possible to use libevent to monitor a file removal/update? Assuming that /var/log/file.1 is removed I want to report it in my program. Is this possible? If yes, how? My operating system is Linux and I want to create a demon that fires…
cateof
  • 6,608
  • 25
  • 79
  • 153
1
vote
1 answer

Async HTTP IO with libevent

I have a program that essentially has two events: EventOne: query from a REST API every minutes and get a number EventTwo: show the number from EventOne on an LED screen The dilemma is: EventOne's REST API is slow, it might take a few seconds to…
D.J. Elkind
  • 367
  • 2
  • 8
1
vote
2 answers

Does libevent process two events concurrently which means I need mutex?

I am experimenting with the libevent library. I defined a few events and I do not create any threads in my code. My question is, if a few events can access/modify the same shared struct, do I need a mutex to lock the critical section to avoid race…
D.J. Elkind
  • 367
  • 2
  • 8
1
vote
0 answers

Configure libevent failed:./configure: line 19401: cannot create temp file for here-document: No such file or directory

I was going to install libevent on CentOS 7. So I went to https://libevent.org/ to download the newest version of libevent(libevent-2.1.12-stable.tar.gz). The operations were: mkdir -r /opt/libevent cd /opt/libevent tar -zxvf…
Up Pu
  • 33
  • 4
1
vote
1 answer

how can I receive all message by libevent

Currently, I use libevent to send and receive messages. The issue I am currently encountering is that I do not receive all messages on the server; and only receive the first message I sent. Client Code: for (int i=0; i < 10 ; i++) { …
Tom
  • 99
  • 7
1
vote
1 answer

Are event_base_loop and event_base_dispatch thread safe?

Are the event_base_loop()(publisher thread) and event_base_dispatch()(subscriber thread) functions thread safe? Recently I checked my application for any synchronization errors using valgrind's helgrind tool. In the report it's mentioned that there…
Harry
  • 2,177
  • 1
  • 19
  • 33
1
vote
4 answers

PHP8/EventListener - Getting Socket instance from file descriptor

PHP8 has introduced Socket class that replaces old socket resource. Now all socket functions works with the instance of this class. The 2nd argument of EventListener's constructor (https://www.php.net/manual/en/class.eventlistener.php) is callback…
1
vote
0 answers

Why is epoll thread-safe but not libevent

I am a bit confused about the difference between epoll and libevent. Libevent is just an encapsulation of epoll. Since epoll is considered to be thread-safe (e.g. Is epoll thread-safe? Is epoll_ctl() safe to be called simultaneously from multiple…
steamgjk
  • 11
  • 1
1
vote
0 answers

Error: We found the libraries for libevent, but we could not find the C header files

I´m trying to install an old Tor version which requires a libevent devel package. I have downloaded a devel package correctly, but and when I run ./configure --with-libevent-dir=/libevent/lib/x86_64-linux-gnu/, I´m getting this output: We found the…
Antonio Sanchez
  • 381
  • 1
  • 3
  • 11
1
vote
0 answers

how CMAKE_C_COMPILER_ID get a value in libevent CMakeLists.txt?

when I compile libevent using cmake, I found some confusing code as follow: if (("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")) set(CLANG 1) endif() if (("${CMAKE_C_COMPILER_ID}" STREQUAL…
Navy
  • 13
  • 2
1
vote
0 answers

Problem installing Event::Lib with libevent on Mac OSX

I am trying to perform a cpan install of Event::Lib on a Mac OSX 10.15.4. When I first tried to run cpan I found it needed the libevent library. I downloaded, built, and installed that. Now I am getting a number of errors with ev_arg not being…
Coltrane58
  • 317
  • 1
  • 4
1
vote
1 answer

Problem with paired bufferevents with libevent2

I have this multithreaded app with a loop for each thread and two paired bufferevents per thread to send/receive data between those and the main thread. This in theory. In practice, bufferevent_pair_new() returns fine, but two bufferevent structures…
Manuel Abeledo
  • 327
  • 2
  • 4
  • 14
1
vote
0 answers

How to implemetation timer by libevent?

I used libevent to implement a timer using multiple event bases.I want to know if this design is optimal? invoke event_base_new() multiple times
louis
  • 11
  • 3
1
vote
2 answers

What's the difference between MQ(RabbitMQ,ActiveMQ...) and network library(ACE, Asio, libevent...)?

Currently, we plan to upgrade our product to use MQ(RabbitMQ or ActiveMQ) for message transfer between server and client. And now we are using a network lib(evpp) for doing so. Because I don't use MQ before, so excpet for a lot of new features of…
Phymin
  • 123
  • 8
1
vote
0 answers

Use one callback for similar requests in libevent http server

Libevent library (https://libevent.org/) provides functionality to create your own HTTP server. As I know, there are two ways to set request handlers (appropriate callbacks and general callback): // Set callback for appropriate request …
Nick
  • 65
  • 1
  • 5