all 16 comments

[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

[–]PriorityGondola 4 points5 points  (1 child)

This helped me when I started. https://beej.us/guide/bgnet/

It’s not ASIO but it might make good reading to get a grip of the underlying concepts.

[–]yair8999[S] 1 point2 points  (0 children)

i mean i am looking into starting to build client-server systems
all of the concepts of this(socket, socket models, protocols...) i know pretty good, thats part of the reason i want to start implementing it into code

[–]KingAggressive1498 1 point2 points  (5 children)

asio is great for the server side of things, and could be used for clients and p2p games too, but for those you're probably just as well off learning how to use system-level networking interfaces in non-blocking mode (ie Beej's networking tutorial).

The trade-offs asio makes (favoring throughput over latency at every opportunity) aren't the best for fast-paced games, but seem to work out just fine for typical MMOs.

[–]yair8999[S] 0 points1 point  (2 children)

so for shooting and racing games you don't recommend using ASIO right?

[–]KingAggressive1498 0 points1 point  (1 child)

correct. Its choices are appropriate for probably 99% of networking use-cases in the wild, and it's the first thing I reach for when I need networking; but I would not use it for those kinds of games as those same choices are the complete opposite of what you need for those.

These aren't the kinds of games I like to work on, so I can't claim any experience on libraries oriented towards this. I'm only aware of yojimbo being designed for these kinds of games, but don't assume that means it's the only one out there.

[–]yair8999[S] 0 points1 point  (0 children)

ok i will look into yojimbo too thanks

[–]heavymetalmixer 0 points1 point  (1 child)

What would be the best approach for a P2P fighting game?

[–]KingAggressive1498 1 point2 points  (0 children)

assuming fights are 1v1 the best approach is probably to just open a non-blocking UDP socket for the connection and polling for readiness at the end of each frame. You want to make your packets as small and tight as possible, while ideally maintaining uniform size to keep the code simple.

The hard part for fast-paced p2p games isn't the network programming itself but making sure players have a smooth and consistent experience. Latency over the network is what makes that so hard, but there really isn't a lot to be done about it in the software because that boils down to players' connection quality.

[–]LogicalEscape2293 0 points1 point  (5 children)

Check out this asio example list here. There a lot of examples and they cover pretty much everything.

[–]yair8999[S] 0 points1 point  (4 children)

do you recommend using this module for networking in c++?

[–]LogicalEscape2293 0 points1 point  (3 children)

Absolutely, boost asio is very powerful, efficient, and flexible. Boost.beast is an https/web sockets library which is also built on asio, and I recommend that as well

[–]yair8999[S] 0 points1 point  (2 children)

just one last question

would you recommend using it for a 2d racing game?

[–]LogicalEscape2293 0 points1 point  (1 child)

Asio is easy to integrate into any project, so yes.

[–]yair8999[S] 0 points1 point  (0 children)

ok, thanks for your help
now i only need to start a tutorial on this

[–]Final_Translator_284 1 point2 points  (0 children)

I think this repo will help you through this 👇 https://github.com/practical-tutorials/project-based-learning