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

how libevent detect that a socket is closed

if I add an event for a specific socket to event loop, for example, a TCP connection socket. then it may happen that the socket is closed, then how will libevent act? can it detect this? thanks!
misteryes
  • 2,167
  • 4
  • 32
  • 58
2
votes
2 answers

ev_timer callback is called earlier than it should be

I have a problem with ev_timer of libev, please look at the code below: static void timeout_cb(struct ev_loop *loop, ev_timer *timer, int revent) { printf("got an timeout event, current time %s\n", get_current_time()); } int main(int argc, char…
Kery
  • 513
  • 8
  • 22
2
votes
3 answers

compile libev (dev) under CentOS

I was wondering if there were instructions somewhere on how to compile libev-dev on Linux (CentOS) 64 bit. I was not able to locate the dev package associated with libev nor any tutorials on its compilation. p.s: no package managers please - since I…
JohnJ
  • 6,736
  • 13
  • 49
  • 82
2
votes
1 answer

libevent kqueue doesn't work on fd returned from zmq_getsockopt()

ORIGINAL POST: I'm writing a service in C programming using libevent and zmq. Msg is pushed from python code to C service using PUSH-PULL pattern. fd received from zmq socket: void *receiver = zmq_socket (base.zmq_ctx, ZMQ_PULL); zmq_connect…
Pritesh Acharya
  • 1,596
  • 5
  • 15
  • 36
2
votes
1 answer

What are my errors using libevent timout events?

I am trying to learn libevent for use in a future project. I am attempting to create a event that calls it's call back function each time it times out. All the call back function does is print "timeout_cb called" to standard out. my code for the…
Edward Goodson
  • 302
  • 1
  • 11
2
votes
1 answer

Libevent writes to the socket only after second buffer_write

Libevent is great and I love it so far. However, on a echo server, the write only sends to the socket on a second write. My writing is from another thread, a pump thread that talks to a db and does some minimal data massaging. I verified this by…
Mickey Kawick
  • 187
  • 1
  • 12
2
votes
3 answers

Windows cygwin gearman ./configure shows "configure: error: Unable to find libevent" error

I am trying to install gearman http://www.phpvs.net/2010/11/30/installing-gearman-and-gearmand-on-windows-with-cygwin/ I downloaded "libevent-2.0.21-stable.tar.gz" and extracted in cygwin's home/libs directory (I created a libs directory myself)…
Sukhrob
  • 901
  • 4
  • 12
  • 34
2
votes
2 answers

How to create tcp-client by libevent

Do You have link to example, how to create the client to echo-server? I need to use libevent, bufervents. This code have connect, but don't write to server: int main() { struct event_base *base; struct evbuffer* ev_buffer; const char…
Alexandre Kalendarev
  • 681
  • 2
  • 10
  • 24
2
votes
1 answer

libevent: raise event on file change

I have the following code: #include #include #include #include #include void fd_cb(int fd,short event,void *arg){ printf("changed\n"); } int main(int argc, const char* argv[]){ …
Eamorr
  • 9,872
  • 34
  • 125
  • 209
2
votes
1 answer

TCP port event callbacks in C using libevent

To make a long story short, i am implementing a mix-net in C. To do this i'm creating several individual daemons which listen on a section of TCP ports (say 31001-31008), receive data on those ports and put it into a buffer (say TCP port 31002 -->…
Chris C
  • 259
  • 2
  • 15
2
votes
1 answer

epool with pyev or select from stdlib in Python?

Did someone measure in Python the speed and usefulness of pyev over standard binding through select from Python stdlib? What are benefits of using pyev over select? pyev is build by C extension, so it is not portable solution. I try to build it…
Robert Zaremba
  • 8,081
  • 7
  • 47
  • 78
2
votes
1 answer

libevent & signal handling (SIGCHLD specifically)

This is somewhat of a followup to related question I found here. In the linked question there is a mention of using signalfd() and using that fd with libevent. In that question the OP does not list why he is using signalfd() as opposed to the…
nhed
  • 5,774
  • 3
  • 30
  • 44
1
vote
2 answers

Too many open files with libevent's evhttp based server

I've created simple evhttp based server. #include #include #include #include #include void handler(struct evhttp_request *req, void *arg) { struct evbuffer *buf; buf = evbuffer_new(); …
Sebastian Sito
  • 163
  • 3
  • 10
1
vote
2 answers

How to compile libevent2 on Windows?

I am trying to compile this libevent2 package to Windows, but currently I can't because the configure script is a shell script (/bin/sh; can't be run in Windows). Is there any way I can compile it or obtain a pre-compiled package? I currently have…
liamzebedee
  • 14,010
  • 21
  • 72
  • 118
1
vote
3 answers

Libevent and file I/O

Does the libevent deal with buffered file I/O? I know it handles sockets pretty good, but does it concern also normal files or it's "only" an epoll/... wrapper?
Cartesius00
  • 23,584
  • 43
  • 124
  • 195