www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Network I/O and streaming in D2

reply Joe Hildebrand <joe.hildebrand webex.com> writes:
On 6/30/10 10:28 AM, "Adam Ruppe" <destructionator gmail.com> wrote:

 For servers, they are still pretty useful. You can use the select()
 call on unix to wait for any one of a set of connections to be ready
 for you, and when it is, you then call the same blocking read/write
 functions. Since  you know ahead of time that they are ready, it
 doesn't actually wait.

Select has been out of favor for quite a while in favor of poll, epoll, kqueues, IO Completion ports, and the like. I'd recommend starting with libevent2 (http://monkey.org/~provos/libevent/) if the license fits, and fire events through the D concurrency mechanisms. Layering blocking APIs on top of this should be pretty easy. -- Joe Hildebrand
Jul 02 2010
next sibling parent reply Johannes Pfau <spam example.com> writes:
On 02.07.2010 09:07, Joe Hildebrand wrote:
 On 6/30/10 10:28 AM, "Adam Ruppe" <destructionator gmail.com> wrote:
 
 For servers, they are still pretty useful. You can use the select()
 call on unix to wait for any one of a set of connections to be ready
 for you, and when it is, you then call the same blocking read/write
 functions. Since  you know ahead of time that they are ready, it
 doesn't actually wait.

Select has been out of favor for quite a while in favor of poll, epoll, kqueues, IO Completion ports, and the like. I'd recommend starting with libevent2 (http://monkey.org/~provos/libevent/) if the license fits, and fire events through the D concurrency mechanisms. Layering blocking APIs on top of this should be pretty easy.

time ago, is there a special reason to use libevent instead of libev? Both seem to be actively developed and liberally licensed (libevent: 3 Clause BSD libev: 2 Clause BSD), but at least for libevent1 libev claims to be faster. Some new benchmarks against libevent2 ( http://lists.schmorp.de/pipermail/libev/2010q2/001033.html ) show no big difference in speed anymore (libev is still faster when using timeouts or many clients). So any special reason to use one rather than the other? -- Johannes Pfau
Jul 02 2010
parent reply Sean Kelly <sean invisibleduck.org> writes:
Johannes Pfau Wrote:
 Just wondering, as libevent was already brought up on the newsgroup some
 time ago, is there a special reason to use libevent instead of libev?
 Both seem to be actively developed and liberally licensed (libevent: 3
 Clause BSD libev: 2 Clause BSD), but at least for libevent1 libev claims
 to be faster. Some new benchmarks against libevent2 (
 http://lists.schmorp.de/pipermail/libev/2010q2/001033.html ) show no big
 difference in speed anymore (libev is still faster when using timeouts
 or many clients). So any special reason to use one rather than the other?

I mentioned libevent simply because I've used it before. From a license standpoint (and features as well), libev is a better choice for Phobos.
Jul 02 2010
parent Johannes Pfau <spam example.com> writes:
On 02.07.2010 18:31, Sean Kelly wrote:
 Johannes Pfau Wrote:
 Just wondering, as libevent was already brought up on the newsgroup some
 time ago, is there a special reason to use libevent instead of libev?
 Both seem to be actively developed and liberally licensed (libevent: 3
 Clause BSD libev: 2 Clause BSD), but at least for libevent1 libev claims
 to be faster. Some new benchmarks against libevent2 (
 http://lists.schmorp.de/pipermail/libev/2010q2/001033.html ) show no big
 difference in speed anymore (libev is still faster when using timeouts
 or many clients). So any special reason to use one rather than the other?

I mentioned libevent simply because I've used it before. From a license standpoint (and features as well), libev is a better choice for Phobos.

I see, thanks for the info. -- Johannes Pfau
Jul 04 2010
prev sibling parent Leandro Lucarella <luca llucax.com.ar> writes:
Sean Kelly, el  2 de julio a las 12:31 me escribiste:
 Johannes Pfau Wrote:
 Just wondering, as libevent was already brought up on the newsgroup some
 time ago, is there a special reason to use libevent instead of libev?
 Both seem to be actively developed and liberally licensed (libevent: 3
 Clause BSD libev: 2 Clause BSD), but at least for libevent1 libev claims
 to be faster. Some new benchmarks against libevent2 (
 http://lists.schmorp.de/pipermail/libev/2010q2/001033.html ) show no big
 difference in speed anymore (libev is still faster when using timeouts
 or many clients). So any special reason to use one rather than the other?

I mentioned libevent simply because I've used it before. From a license standpoint (and features as well), libev is a better choice for Phobos.

I did a simple libev wrapper for D1 once. I'm not maintaining it much, but the library doesn't change much and it's pretty thin, so adapting it to D2 shouldn't be too much work; it could serve as a start point. If you want to use it for anything, I have no problem changing the license of the wrapper, if needed. http://llucax.com.ar/proj/ev.d/index.html -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- DONAN UN PENE EN NICARAGUA -- Crónica TV
Jul 02 2010