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
0
votes
1 answer

Do I need to evconnlistener_disable() before fork()?

I am developing a server app with libevent now. The server sometimes needs to exec some external command (i.e. fork() then exec()). My concern is that, right after fork(), both the parent and the child might be effectively listening, and the child…
grizzlybears
  • 492
  • 2
  • 9
0
votes
2 answers

recv() not triggering with libevent

I am trying to connect to the local openvpn client over its managment socket and query its state/status. I have implemented the follow program with libevent support. #include #include #include #include…
SAS
  • 75
  • 2
  • 10
0
votes
1 answer

Does libevent allow to run callback for timer/io in a different thread?

Due to some application reasons I need to run callback for timer/io events in a different thread. Example: void EventLoop::createIOEvent(int fd, short kind, event_cb originalCallback, void* originalUserData) { ... const auto…
Igor
  • 1,029
  • 9
  • 21
0
votes
0 answers

libevent gives data that I'm not expecting?

So I've been trying to find out why I receive information through my buffer that I know for a fact that aren't being sent by the client. Does anyone else where the problem lies? I've tried googling and ofcourse stackoverflow but still couldn't find…
0
votes
3 answers

Multiple tcp connections in single thread with using libevent or boost::asio. It's possible?

Is it possible to use libevent for create multiple tcp connections to different servers in one thread? Could you write a sample implementation of such a task? I have done so, but not sure that it's right: ... int num_of_connect = 5; /*for…
trafalgarx
  • 702
  • 2
  • 10
  • 13
0
votes
0 answers

Issues building a multi threaded C++ server

Currently, I am trying to explore more about libevent server library. I came across this example†, which I ran with main as: † Program to run after downloading libevent library main.cpp #include #include…
Kay
  • 13
  • 3
0
votes
2 answers

CMake can't find libevent on macOS

I've installed libevent on macOS - $ brew install libevent I'm trying to import it in my CMakeLists.txt - cmake_minimum_required(VERSION 3.14) project(xyz) set(CMAKE_CXX_STANDARD 17) find_package(libevent REQUIRED) I get the following CMake error…
Gautham
  • 766
  • 7
  • 15
0
votes
1 answer

pthread adds a socket to libevent but exits

Is it undefined behavior, if a pthread adds a fd to libevent (event_new -> cbk()) but terminates ? I see that the cbk() gets invoked on EV_READ!
Ani
  • 1,448
  • 1
  • 16
  • 38
0
votes
0 answers

Monitor Raspberry Pi GPIO pin change with libevent

I have a server (C++) relying on libevent to detect various events like incoming network connections and traffic, running on a raspberry pi. In addition to network ports I'd also like to monitor a few Raspberry PI's GPIO pins for changes triggered…
tglas
  • 949
  • 10
  • 19
0
votes
1 answer

Can EventFD be used with libEvent2?

I have multiple processes doing IPC over shared memory. I use a cross process shared EventFD to trigger when a message is available. To listen to the trigger I was using Epoll and it works fine. But I need to switch to using libEvent2 for other…
Yasser Asmi
  • 1,150
  • 2
  • 12
  • 27
0
votes
1 answer

What will do after call bufferevent_free if output buffer have data?

For a connected bufferevent(bev), client call shutdown(fd, SHUT_WR); server receive BEV_EVENT_EOF if evbuffer_get_length(bufferevent_get_output(bev)) > 0, then call bufferevent_free(bev) What will do ? send all data and free or just give up data…
Yunbin Liu
  • 1,484
  • 2
  • 11
  • 20
0
votes
1 answer

Can I use C++11 lambda with libevent?

There is a callback function type in libevent used by event_new(). typedef void (*event_callback_fn)(evutil_socket_t, short, void *); I want use lambda with event_callback_fn. If I use [](evutil_socket_t fd, short flags, void *…
DinoStray
  • 696
  • 1
  • 6
  • 20
0
votes
1 answer

cannot build libevent on windows

So I have been trying to build libevent on Windows. However, it keeps giving me the following output when I run nmake MakeFile.nmake... cl /IWIN32-Code /IWIN32-Code/nmake /Iinclude /Icompat /DHAVE_CONFIG_H /I. /Ox /W3 /wd4996 /nologo /c…
0
votes
1 answer

How install libevent extension in Apache2

I try to install libevent in the php of my Apache2.4 in Ubuntu 16.04 but I can't do it. I have this snippet of code for know if the library is detected in a test page on my apache server : $test = event_base_new(); It says to me Call to…
Lafdoma
  • 41
  • 8
0
votes
1 answer

3 sockets created for one libevent bind on Windows?

I'm writing a BitTorrent client to learn some more about networking, and I've got something that I'm struggling to Google for. As part of the BT spec, I need a server to listen for peer connections to my computer. In the win32 port, I have code like…
Charles
  • 953
  • 1
  • 8
  • 19