[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Proper socket shutdown.
On Sat, Oct 30, 2010 at 12:03 PM, Ralph Castain <rhc@xxxxxxxxxxxx> wrote:
> Just wondering: would it make sense to provide a libevent API for this?
Yes, what kind of API did you have in mind? The easiest would be
something to implement bufferevent_flush(BEV_FINSISHED) for sockets,
and define it to a) write as much as possible, and b) if all data is
written, shutdown() the socket.
But it seems that what people usually want instead is something that
will start writing, wait till all data is written, then shutdown() the
socket. I'm a little less thrilled with writing one of these, since
it's just a wrapper around other functionality, but it does seem to be
the kind of thing that people. It should probably be called something
like ... well, bufferevent_flush() is taken.
bufferevent_flush_and_shutdown(), maybe ? It should call the event
callback with a new event type, BEV_SENT_CLOSE, when it's finished.
It should also respect write timeouts.
Does anybody care strongly about this to try writing the code and tests?
> I ask because proper shutdown is important to a number of us, and it seems a shame that we all have to independently sprinkle the code throughout our programs wherever sockets are used. On the surface, at least, it would appear that a simple API could take care of this for us.
Sure; it would be good to have something like this in 2.1. Somebody
should write one. If it's _totally noninvasive_, well tested, and we
can get it done inside the next week or so, it might even work out for
2.0.
yrs,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.