D alternative for node.js's socket.IO?

Nick Sabalausky (Abscissa) SeeWebsiteToContactMe at semitwist.com
Mon Oct 22 03:05:06 UTC 2018


On 10/21/18 4:58 PM, Fleel wrote:
> On Sunday, 21 October 2018 at 20:41:41 UTC, JN wrote:
>> On Sunday, 21 October 2018 at 20:14:46 UTC, Fleel wrote:
>>> Does anyone know of a good D alternative for the socket.IO server 
>>> (https://socket.io)? I would like to transition my server from 
>>> node.js to D, but I can't find any D equivalents to socket.IO. (I've 
>>> seen http://socket.io.dub.pm, but it is dead). Are there any good D 
>>> libraries that can do the same thing as socket.IO? Thanks!

I'm afraid I'm not familiar with socket.io, and the homepage doesn't 
seem to tell me much (it doesn't even say whether it uses TCP or UDP). 
But that said, in D, the gold-standard for pretty much *anything* 
related to networking and sockets is Vibe.D: http://vibed.org/

If the network/socket functionality you're looking for exists in D, then 
it's probably in either the standard library or in Vibe.D. If what 
you're looking for doesn't exist, then it can certainly be built on top 
of Vibe.D.

> 
> Can std.socket provide a realtime connection between the client(web 
> browser) and the server, like for a chatroom or realtime multiplayer game?

For something like a chatroom, and the vast majority of any networking 
you'd want to do, Vibe.D definitely can. Plain old ordinary TCP is 
perfectly sufficient for something like chatrooms, and Vibe.D supports 
TCP clients/servers very well. For other things, Vibe.D had equally good 
support for UDP. So that alone makes Vibe.D universally useful, plus the 
way its job system works gives you all the benefits of async networking 
code without having to deal with the mess of callback-oriented programming.

For a realtime multiplayer games though, that's notoriously a whole 
different can of worms. For that, you definitely do need UDP (which 
again, Vibe.D supports). But, UDP being what it is, you'd still need to 
design your program to handle UDP's inherently unguaranteed nature. 
Vibe.D doesn't have a gaming-oriented networking system built on top of UDP.

You could also look into ZeroMQ: https://code.dlang.org/packages/zeromq 
I haven't used ZeroMQ myself though, so no promises about how well it 
works, but it may be worth looking into.


More information about the Digitalmars-d mailing list