Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
December 17, 2014 Non-blocking UDP calls using std.socket | ||||
---|---|---|---|---|
| ||||
I've written a small program that uses UdpSocket (std.socket) to query a DNS server for selected records. It works as expected, but I would like to try a non-blocking approach. The last time I wrote socket code (without a supporting library) was over a decade ago, and even then it was not my forté. Does anyone know of a cross-platform (Mac, Win, *nix) D library that encapsulates the asynchronous calls in a simple API? If I'm missing something in std.socket (that does the [non-blocking] trick) I would appreciate it being pointed out to me. And, if it's not too much trouble, I would appreciate a code snippet or link to a sample. Thanks, Andre Artus |
December 17, 2014 Re: Non-blocking UDP calls using std.socket | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre Artus | On 17/12/2014 9:20 p.m., Andre Artus wrote: > I've written a small program that uses UdpSocket (std.socket) to query a > DNS server for selected records. > > It works as expected, but I would like to try a non-blocking approach. > > The last time I wrote socket code (without a supporting library) was > over a decade ago, and even then it was not my forté. > > Does anyone know of a cross-platform (Mac, Win, *nix) D library that > encapsulates the asynchronous calls in a simple API? > > If I'm missing something in std.socket (that does the [non-blocking] > trick) I would appreciate it being pointed out to me. > > And, if it's not too much trouble, I would appreciate a code snippet or > link to a sample. > > Thanks, > > Andre Artus Have you looked at vibe.d? https://github.com/rejectedsoftware/vibe.d/blob/master/examples/udp/source/app.d |
December 17, 2014 Re: Non-blocking UDP calls using std.socket | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre Artus | V Wed, 17 Dec 2014 08:20:42 +0000 Andre Artus via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> napsáno: > I've written a small program that uses UdpSocket (std.socket) to query a DNS server for selected records. > > It works as expected, but I would like to try a non-blocking approach. > > The last time I wrote socket code (without a supporting library) was over a decade ago, and even then it was not my forté. > > Does anyone know of a cross-platform (Mac, Win, *nix) D library that encapsulates the asynchronous calls in a simple API? > > If I'm missing something in std.socket (that does the [non-blocking] trick) I would appreciate it being pointed out to me. > > And, if it's not too much trouble, I would appreciate a code snippet or link to a sample. > > Thanks, > > Andre Artus https://github.com/etcimon/libasync http://code.dlang.org/packages/libevent http://code.dlang.org/packages/libev http://code.dlang.org/packages/libuv |
December 17, 2014 Re: Non-blocking UDP calls using std.socket | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rikki Cattermole | -- snip --
>
> Have you looked at vibe.d?
> https://github.com/rejectedsoftware/vibe.d/blob/master/examples/udp/source/app.d
Thanks Rikki,
I saw that before, but I was left with the impression that its doing blocking calls in a thread (which could very well be the simplest answer). I'll give it a bash.
I wrote an equivalent program in C# using the asynch socket calls and the Task Parallel Library and the result was at least a ten fold speed increase. I would like to match, and preferably better, that performance in a D program. I realize that the task is predominantly network bound so D doesn't get much of its native advantage.
|
December 17, 2014 Re: Non-blocking UDP calls using std.socket | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozák | -- snip --
>
> https://github.com/etcimon/libasync
> http://code.dlang.org/packages/libevent
> http://code.dlang.org/packages/libev
> http://code.dlang.org/packages/libuv
Thanks Daniel,
These links look interesting. Perhaps libasync could do the trick.
|
December 17, 2014 Re: Non-blocking UDP calls using std.socket | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andre Artus | On Wednesday, 17 December 2014 at 09:37:47 UTC, Andre Artus wrote:
> -- snip --
>>
>> Have you looked at vibe.d?
>> https://github.com/rejectedsoftware/vibe.d/blob/master/examples/udp/source/app.d
>
> Thanks Rikki,
>
> I saw that before, but I was left with the impression that its doing blocking calls in a thread (which could very well be the simplest answer). I'll give it a bash.
It uses fibers to make it look as if it were a synchronous, blocking API, but under the hood it does asynchronous, non-blocking calls in an event loop.
|
Copyright © 1999-2021 by the D Language Foundation