Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 20, 2014 async socket programming in D? | ||||
---|---|---|---|---|
| ||||
I know the socket has the nonblocking settings, but how would I actually go around using it in D? Is there a specific procedure for it to work correctly etc. I've taken a look at splat.d but it seems to be very outdated, so that's why I went ahead and asked here as I'd probably have to end up writing my own wrapper. |
April 21, 2014 Re: async socket programming in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bauss | On Sunday, 20 April 2014 at 22:44:28 UTC, Bauss wrote:
> I know the socket has the nonblocking settings, but how would I actually go around using it in D? Is there a specific procedure for it to work correctly etc.
>
>
> I've taken a look at splat.d but it seems to be very outdated, so that's why I went ahead and asked here as I'd probably have to end up writing my own wrapper.
The "Socket" class has "blocking" property that is boolean. Before starting to listening as a server socket, or connecting to a server as client, if you set it to "false", then you can use them (waiting for client with `accept` or receiving messages) as asynchronous.
Already as you know, a client that is created from the `accept` method of non-blocking server socket is non-blocking as well. So you don't have to do anything about it.
|
April 21, 2014 Re: async socket programming in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bauss | On 2014-04-20 18:44, Bauss wrote: > I know the socket has the nonblocking settings, but how would I actually > go around using it in D? Is there a specific procedure for it to work > correctly etc. > > > I've taken a look at splat.d but it seems to be very outdated, so that's > why I went ahead and asked here as I'd probably have to end up writing > my own wrapper. I was actually working on this in a new event loop for vibe.d here: https://github.com/globecsys/vibe.d/tree/native-events/source/vibe/core/events I've left it without activity for a week b/c I'm currently busy making a (closed source) SSL library to replace openSSL in my projects, but I'll return to this one project here within a couple weeks at most. It doesn't build yet, but you can probably use some of it at least as a reference, it took me a while to harvest the info on windows and linux kernels for async I/O. Some interesting parts like that which you wanted are found here: https://github.com/globecsys/vibe.d/blob/native-events/source/vibe/core/events/epoll.d#L403 I think I was at handling a new connection or incoming data though, so you won't find accept() or read callbacks, but with it I think it was pretty much ready for async TCP. |
April 21, 2014 Re: async socket programming in D? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etienne Cimon | On 2014-04-21 00:32, Etienne Cimon wrote:
> On 2014-04-20 18:44, Bauss wrote:
>> I know the socket has the nonblocking settings, but how would I actually
>> go around using it in D? Is there a specific procedure for it to work
>> correctly etc.
>>
>>
>> I've taken a look at splat.d but it seems to be very outdated, so that's
>> why I went ahead and asked here as I'd probably have to end up writing
>> my own wrapper.
>
> I was actually working on this in a new event loop for vibe.d here:
> https://github.com/globecsys/vibe.d/tree/native-events/source/vibe/core/events
>
>
> I've left it without activity for a week b/c I'm currently busy making a
> (closed source) SSL library to replace openSSL in my projects, but I'll
> return to this one project here within a couple weeks at most.
>
> It doesn't build yet, but you can probably use some of it at least as a
> reference, it took me a while to harvest the info on windows and linux
> kernels for async I/O. Some interesting parts like that which you wanted
> are found here:
> https://github.com/globecsys/vibe.d/blob/native-events/source/vibe/core/events/epoll.d#L403
>
>
> I think I was at handling a new connection or incoming data though, so
> you won't find accept() or read callbacks, but with it I think it was
> pretty much ready for async TCP.
But of course, nothing stops you from using vibe.d with libevent ;)
|
Copyright © 1999-2021 by the D Language Foundation