RejectedSoftware Forums

Sign up

Using ENet library with vibe.d

Hello again,

I'm reasonably new to networking and concurrency, so here goes:

I'm interested in designing a game server using vibe-d.
My primary use of vibe-d is the fiber-aware concurrency mechanisms.

Previous to vibe-d, I was using ENet[1] for my network protocol:

ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol).
The primary feature it provides is optional reliable, in-order delivery of packets.

ENet is supposedly reasonably thread-safe[2] although I don't think that's necessary.

It would be optimal for me to utilize ENet for networking with vibe-d for concurrency;
however, I don't want to be in a situation wherein performance is heavily degraded due to this combination.

ENet, by default, uses synchronous blocking sockets. However, a timeout can be set to 0 which results in non-blocking behavior.

ENet provides enet_host_service which functions similar to a recv on UDP or TCP.
My architecture is basically to have on fiber constantly calling enet_host_service
and then if data is received, create a new fiber to handle whatever action (connection, movement, etc.)

  • Is this architecture reasonably scalable?
  • Is having one fiber constantly recving good enough to handle a thousand concurrent players, all performing actions in a 3D game world?
  • If not, then how is this problem resolved?

Sorry if my provided information is a little too unspecific. I mostly just want to make sure I'm not way off track here.

Regards,
Kelet

Re: Using ENet library with vibe.d

Hmm, the message boards seem to not like my sourcing format!

[1] http://enet.bespin.org/
[2] http://enet.bespin.org/FAQ.html

Regards,
Kelet

Re: Using ENet library with vibe.d

And of course, you can assume that I'm not taking into account
any performance bottlenecks that ENet alone may have in these
regards. Although if you know of any, I'd like to know as well.

Regards,
Kelet

Re: Using ENet library with vibe.d

On Mon, 20 Jan 2014 03:34:33 GMT, Kelet wrote:

Hello again,

I'm reasonably new to networking and concurrency, so here goes:

I'm interested in designing a game server using vibe-d.
My primary use of vibe-d is the fiber-aware concurrency mechanisms.

Previous to vibe-d, I was using ENet[1] for my network protocol:

ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol).
The primary feature it provides is optional reliable, in-order delivery of packets.

ENet is supposedly reasonably thread-safe[2] although I don't think that's necessary.

It would be optimal for me to utilize ENet for networking with vibe-d for concurrency;
however, I don't want to be in a situation wherein performance is heavily degraded due to this combination.

ENet, by default, uses synchronous blocking sockets. However, a timeout can be set to 0 which results in non-blocking behavior.

ENet provides enet_host_service which functions similar to a recv on UDP or TCP.
My architecture is basically to have on fiber constantly calling enet_host_service
and then if data is received, create a new fiber to handle whatever action (connection, movement, etc.)

  • Is this architecture reasonably scalable?
  • Is having one fiber constantly recving good enough to handle a thousand concurrent players, all performing actions in a 3D game world?
  • If not, then how is this problem resolved?

Sorry if my provided information is a little too unspecific. I mostly just want to make sure I'm not way off track here.

[1]: http://enet.bespin.org/
[2]: http://enet.bespin.org/FAQ.html

Regards,
Kelet

I've just taken a quick look, but if ENetSocket is an alias for int or SOCKET or if it is possible to somehow get the socket number, you can use the new createSocketFileDescriptorEvent to avoid polling (see this thread). In that case everything should run reasonably efficient (not sure how ENet handles the zero timeout, but that shouldn't be an issue because you'd basically never run into it).

/markdown: you can use double brackets [[1]] or labeled references [ENet][1] to make the references into links.

Re: Using ENet library with vibe.d

On Mon, 20 Jan 2014 10:32:01 GMT, Sönke Ludwig wrote:

I've just taken a quick look, but if ENetSocket is an alias for int or SOCKET or if it is possible to somehow get the socket number, you can use the new createSocketFileDescriptorEvent to avoid polling (see this thread). In that case everything should run reasonably efficient (not sure how ENet handles the zero timeout, but that shouldn't be an issue because you'd basically never run into it).

However, I've done some research on libevent and now have a much better perspective on what's going on. I didn't know that UDPConnection's recv registered an event and was blocking. But now it makes sense. Unfortunately, this makes the ENet library less than useful in this scenario. I think I'll just cook something of my own up and use TCP in the meantime.

Thanks,
Kelet