On Mon, Feb 8, 2010 at 4:10 PM, Jj Jack <[email protected]> wrote: > After some digging, I've managed to figure it out. > > The order of calls makes all the difference, so, it would be nice if you > explicitly mentioned it in your book, Nick (great resource, btw!). > > This works: > > > bufferevent_setcb(bev, readcb, NULL, eventcb, NULL); > > if (bufferevent_socket_connect(bev,(struct sockaddr *)&sin, > sizeof(sin)) < 0) > { > bufferevent_free(bev); > } > > bufferevent_setwatermark(bev, EV_READ, X, 0); > bufferevent_enable(bev, EV_READ|EV_WRITE); > bufferevent_set_timeouts(bev, &tv, &tv); > > But, setting the watermarks, or timeouts before the socket_connect doesn't, > which, is quite confusing, as you can add data to the buffer before adding > the connection, this makes it quite confusing, imo, as it seems arbitrary. > > Regardless, I hope this'll help someone out. >
Actually, this is a bug IMO. You ought to be allowed to set the watermark and timeouts before the socket_connect and have it work fine. If you can't, that's a problem in the code. If you get a chance, do you think you'd be able to a) reproduce this under the version of Libevent from the git repository [1], and if the problem is still there, b) write a unit test for it [2], so we can start to track down what the problem is? If you don't have time to do those, it would be great if you could file a bug [3] so we don't forget about this. [1] The official git repository is at git://levent.git.sourceforge.net/gitroot/libevent [2] The unit tests for bufferevents are in the source at test/regress_bufferevent.c ; the ones later in the file are written in a better style. [3] The trackers are here: https://sourceforge.net/tracker/?group_id=50884 Thanks again, -- Nick *********************************************************************** To unsubscribe, send an e-mail to [email protected] with unsubscribe libevent-users in the body.
