I usually use two different events for read and write, too.  For
streaming IO, like reading and writing from a TCP socket, you might
also want to look into bufferevents which abstract a lot of the
low-level details away for you.

Niels.

On 4/1/06, Edward Chan <[EMAIL PROTECTED]> wrote:
> Cool.  Thanks.  Is there any advantage/disadvantage to using 2 event
> types (one for read, and one for write) per fd as opposed to just 1
> event for both read/write per fd?  The reason I thought about using 2
> events is so I don't have to call event_del and event_set all the time.
> For example, when I get a read event, but still have a pending write
> event. I would like to remove the read event, but that means I would
> have to call event_del, then call event_set again with only EV_WRITE.
> And similarly if I get a write but still waiting for a read, I'd have to
> call event_del, and then event_set again with only EV_READ.  Does that
> make sense?  Would 2 events be the better option here?  Or am I totally
> not getting it?
>
> Ed
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
> > Niels Provos
> > Sent: Saturday, April 01, 2006 7:28 AM
> > To: Edward Chan
> > Cc: libevent-users@monkey.org
> > Subject: Re: [Libevent-users] EV_READ/EV_WRITE
> >
> > Yes, that's fine.  As long as its a different event type.
> >
> > Niels.
> >
> > On 3/31/06, Edward Chan <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Is it ok to use 2 different struct event's for the same fd?
> >  In other
> > > words, can I do something like this:
> > >
> > > event_set(&wevent, fd, EV_WRITE, onWriteNotify, arg);
> > > event_add(&wevent, 0); ...
> > > event_set(&revent, fd, EV_READ, onReadNotify, arg);
> > event_add(&revent,
> > > 0); _______________________________________________
> > > Libevent-users mailing list
> > > Libevent-users@monkey.org
> > > http://monkey.org/mailman/listinfo/libevent-users
> > >
> > >
> > >
> >
> _______________________________________________
> Libevent-users mailing list
> Libevent-users@monkey.org
> http://monkey.org/mailman/listinfo/libevent-users
>
>
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to