digitalmars.D.learn - async socket programming in D?
- Bauss (6/6) Apr 20 2014 I know the socket has the nonblocking settings, but how would I
- Tolga Cakiroglu (9/15) Apr 20 2014 The "Socket" class has "blocking" property that is boolean.
- Etienne Cimon (14/20) Apr 20 2014 I was actually working on this in a new event loop for vibe.d here:
- Etienne Cimon (2/24) Apr 20 2014 But of course, nothing stops you from using vibe.d with libevent ;)
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.
Apr 20 2014
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.
Apr 20 2014
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.
Apr 20 2014
On 2014-04-21 00:32, Etienne Cimon wrote:On 2014-04-20 18:44, Bauss wrote:But of course, nothing stops you from using vibe.d with libevent ;)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.
Apr 20 2014