Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
July 12, 2015 socket server help | ||||
---|---|---|---|---|
| ||||
Hello, I have a project of updater for a game with few functions for administrate the game and for this i need a server to communicate with my client side (written in C#). I started to create the server but i have a problem with the "async" part, i tried std.concurrency for the receive thread but i have a problem with spawn function ("template std.concurrency.spawn cannot deduce function from argument types !()(void delegate(Tid ownerTid), Tid)"). I'm not sure of this part and i don't know how to achieve that. The link of my server.d : https://github.com/Adwelean/EmperadorServer/blob/master/source/network/server.d I'd like to know how i could do for create this part. Sorry for my basic English, Quentin |
July 12, 2015 Re: socket server help | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adwelean | On 12/07/2015 2:53 p.m., Adwelean wrote:
> Hello,
>
> I have a project of updater for a game with few functions for
> administrate the game and for this i need a server to communicate with
> my client side (written in C#).
>
> I started to create the server but i have a problem with the "async"
> part, i tried std.concurrency for the receive thread but i have a
> problem with spawn function ("template std.concurrency.spawn cannot
> deduce function from argument types !()(void delegate(Tid ownerTid),
> Tid)").
>
> I'm not sure of this part and i don't know how to achieve that.
>
> The link of my server.d :
> https://github.com/Adwelean/EmperadorServer/blob/master/source/network/server.d
>
>
> I'd like to know how i could do for create this part.
>
> Sorry for my basic English,
> Quentin
Perhaps try vibe.d?
It does support what you want, automatically.
|
July 12, 2015 Re: socket server help | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adwelean Attachments: | On Sun, 12 Jul 2015 02:53:57 +0000, Adwelean wrote: > Hello, > > I have a project of updater for a game with few functions for administrate the game and for this i need a server to communicate with my client side (written in C#). > > I started to create the server but i have a problem with the "async" > part, i tried std.concurrency for the receive thread but i have a > problem with spawn function ("template std.concurrency.spawn cannot > deduce function from argument types !()(void delegate(Tid ownerTid), > Tid)"). > > I'm not sure of this part and i don't know how to achieve that. > > The link of my server.d : https://github.com/Adwelean/EmperadorServer/blob/master/source/network/ server.d > > I'd like to know how i could do for create this part. the problem is that you cannot spawn a *delegate*, only *function*. i.e. `_receive` must be a free function, not a class/struct method. free function doesn't require context pointers and called "function". method does require context pointer (`this`, to access class/struct fields), so it's "delegate" (a "fat pointer" under the hood, incompatible with simple pointers). note that compiler is not smart enough to see that some method never accesses fields of it's class/struct. so, you have to make your `_receive` either free function or static method -- it doesn't access class fields anyway, so it shouldn't be hard. |
July 12, 2015 Re: socket server help | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rikki Cattermole Attachments: | On Sun, 12 Jul 2015 15:44:44 +1200, Rikki Cattermole wrote:
> Perhaps try vibe.d?
> It does support what you want, automatically.
most of the time vibe.d seems to be overkill. that's like building a space ship to visit Aunt Ellie, who lives in a town nearby.
|
July 12, 2015 Re: socket server help | ||||
---|---|---|---|---|
| ||||
Posted in reply to ketmar | On 12/07/2015 5:13 p.m., ketmar wrote: > On Sun, 12 Jul 2015 15:44:44 +1200, Rikki Cattermole wrote: > >> Perhaps try vibe.d? >> It does support what you want, automatically. > > most of the time vibe.d seems to be overkill. that's like building a > space ship to visit Aunt Ellie, who lives in a town nearby. That seems like a great idea! Let's build space ships. After all, its not like it's rocket science. http://www.stuff.co.nz/the-press/news/69903405/rocket-lab-to-bring-200-jobs-to-canterbury-region But seriously, vibe.d is also pretty easy for most use cases. Hence why I'm saying it. |
July 12, 2015 Re: socket server help | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rikki Cattermole Attachments: | On Sun, 12 Jul 2015 17:32:23 +1200, Rikki Cattermole wrote:
> But seriously, vibe.d is also pretty easy for most use cases. Hence why I'm saying it.
that's until your operations are very-very fast, or your libraries have async API. hit the synchronous API, and everything will start turning to a mess, with threads, locks and other niceties onboard.
not that vibe.d is bad or limited -- it was designed to work with async APIs, and it does exactly that, and does that good.
|
July 12, 2015 Re: socket server help | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adwelean | Finally, I decide to use https://github.com/etcimon/libasync and now it work well. Thank you for your answers. |
Copyright © 1999-2021 by the D Language Foundation