On Mon, 2009-05-18 at 12:37 -0400, Nick Mathewson wrote:
> On Mon, May 18, 2009 at 05:26:04PM +0200, q6Yr7e0o nIJDVMjC wrote:
> > Hi,
> > 
> > 
> > can somebody guide me how to write a simple echo server using libevent 2.0?
> > I've read into the sources of libevent (especially http.c) because i wanted
> > to know how to bind to a socket, accept new connections and read/write async
> > to the network.
> > 
> > But there are so many interal functions (like bind_socket bind_socket_ai)
> > which i have to copy (?) in order to bind to a socket that i think i got
> > something wrong.
> 
> I wouldn't look to http.c for examples; it was originally written for
> a much older version of the API, and though it has been updated since
> then, there are still a fair number of new interfaces that it isn't
> using yet.
> 
> For one example of how to use the 2.0.1-alpha API, you could have a
> look at chapter 1 of
>       http://www.wangafu.net/~nickm/libevent-book/ .
> 
> That's still a pretty ungainly way to do a server, though.  In
> 2.0.2-alpha, there will be a new "evconnlistener" API to wrap most of
> the busywork of listening for new connections.  I've attacked a quick
> echo server written with it to this email.  [It works for me on Linux;
> haven't tested it anywhere else.]
> 
> I hope we can get Libevent 2.0.2-alpha released this week.  Until
> then, you can use subversion to fetch the latest code from the
> repository at
> 
>    https://levent.svn.sourceforge.net/svnroot/levent/trunk/libevent
> 
> yrs,

Thanks for everyone's work on libevent, and also Nick's new
libevent-book pages (even I didn't read it yet since I am on some other
projects).

Personally I'd like to see some more sample code/apps coming with
libevent release, instead of books or api docs in details. Code can tell
all the truth to a coder and for a lazy coder as me, I like to copy and
paste functions to my editor ;-)

The samples may have some app frameworks (e.g. show how to fork and
re-set event base, multi-thread), and some how-to in details (e.g. how
to get connect event with libevent/eventbuffer, how to handle process
runs out of number of fd...) 

Neils/Nick may build a list of samples then users like me could
contribute the implement, then other users can use and improve the
code. 


Cheers,

Arthur

_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to