socket server help
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jul 11 22:09:26 PDT 2015
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150712/2154248a/attachment.sig>
More information about the Digitalmars-d-learn
mailing list