www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - socket server help

reply "Adwelean" <quentin.joseph outlook.com> writes:
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
Jul 11 2015
next sibling parent reply Rikki Cattermole <alphaglosined gmail.com> writes:
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.
Jul 11 2015
parent reply ketmar <ketmar ketmar.no-ip.org> writes:
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=20 space ship to visit Aunt Ellie, who lives in a town nearby.=
Jul 11 2015
parent reply Rikki Cattermole <alphaglosined gmail.com> writes:
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.
Jul 11 2015
parent ketmar <ketmar ketmar.no-ip.org> writes:
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=20 async API. hit the synchronous API, and everything will start turning to=20 a mess, with threads, locks and other niceties onboard. not that vibe.d is bad or limited -- it was designed to work with async=20 APIs, and it does exactly that, and does that good.=
Jul 11 2015
prev sibling next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
On Sun, 12 Jul 2015 02:53:57 +0000, Adwelean wrote:

 Hello,
=20
 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#).
=20
 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)").
=20
 I'm not sure of this part and i don't know how to achieve that.
=20
 The link of my server.d :
 https://github.com/Adwelean/EmperadorServer/blob/master/source/network/
server.d
=20
 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=20 function doesn't require context pointers and called "function". method=20 does require context pointer (`this`, to access class/struct fields), so=20 it's "delegate" (a "fat pointer" under the hood, incompatible with simple=20 pointers). note that compiler is not smart enough to see that some method never=20 accesses fields of it's class/struct. so, you have to make your `_receive` either free function or static=20 method -- it doesn't access class fields anyway, so it shouldn't be hard.=
Jul 11 2015
prev sibling parent "Adwelean" <quentin.joseph outlook.com> writes:
Finally, I decide to use https://github.com/etcimon/libasync and 
now it work well.

Thank you for your answers.
Jul 12 2015