[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Unable to construct simple socket client with bufferevent



On Wed, Mar 31, 2010 at 11:53 AM, Anomit Ghosh <anomit.ghosh@xxxxxxxxx> wrote:
> I'm basically trying to a write a very simple echo server/client
> combination, just for trying out libevent. The server doesn't use
> libevent's bufferevent, but the client does.
>
> Code for server: http://codepad.org/nP0KsfPY
> Code for client: http://codepad.org/XRJAVg5m
>
> The problem seems to be that even though the connection is established
> but the server isn't receiving any data from the client and it quits.
> Where am I going wrong?

Your client is never actually entering an event loop (as by calling
event_base_loop()), so it will exit immediately.  You need to call
event_base_loop at some point, or libevent will never actually try to
get and respond to events.  Also, your socket needs to be nonblocking.

yrs,
-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.