Networking in C++ Part #1: MMO Client/Server, ASIO & Framework Basics
Why Stack Overflow recommends it
Stack Overflow users link it as a practical, hands-on walkthrough of ASIO networking and a thread-safe message queue, and as the basis for their own client/server code.
Recommended by 1 people across 1 different months, 2020 to 2022.
What it is
First part of javidx9's series on building a reusable client/server networking framework in C++ with ASIO, ending in a simple MMO game. It covers setting up ASIO, the general challenges of networking, and the start of the framework's basic components.
What people said
Strong rec Francis Cugler · 2020-10 · Stack Overflow · on “Designing a threadsafe queue that has RAII semantics”
Here's a Youtube video from javidx9 that is based on client-server network programming, and towards the end of the video he implements and explains this exact concept of a thread-safe queuing interface framework that both the client and server objects will use. It is very insightful, you might want to check it out. It's definitely worth the time! The video is about an hour long and is part one of a mini-series of videos. [this video]
Cites domis86 · 2021-01 · Stack Overflow · on “How pixiJS and socket.io can work togheter? (General question)”
I see two problems here: First problem - separation of "game logic loop" and "animation loop": In the code snippet which you pasted in your question your game logic ("state()" call) is tied to rendering logic / animation. This way the game logic update (state) needs to wait for rendering, and rendering needs to wait for game logic update. Also what if for example: the "game logic update" is very heavy and should be called every 0.2 seconds - so not so often as rendering which happens ~60 times per seconds (60 FPS)? What can help to solve this issue is to have 2 independent loops - lets call them: "game logic loop" and "animation loop". function gameLogicLoop() updateState(); setTimeout(funct
Cites malloc · 2021-03 · Stack Overflow · on “How to fix Boost::Asio Client Http request error?”
I'm trying to lean Boost [LINK] ::Asio networking library for C++ by watching this video [this video] but I stuck at making request using threads asynchronously. The code : #include "stdafx.h" #include <iostream> #include <boost/asio.hpp> #include <boost/asio/ts/buffer.hpp> #include <boost/asio/ts/internet.hpp> #include <boost/system/error_code.hpp> std::vector<char> vBuffrer(20 * 1024); void GrabSomeData(boost::asio::ip::tcp::socket& socket) { socket.async_read_some(boost::asio::buffer(vBuffrer.data(), vBuffrer.size()), [&](std::error_code ec, std::size_t length) //boost::system::error_code ec { if (!ec) { std::cout << "\n\nRead" << length << "bytes\n\n"; for (int i = 0; i < length; i++) std::co
Cites potter john · 2022-03 · Stack Overflow · on “Asio difference between work(), require() and make_work_guard()”
Sorry to interrupt, I am a newbie in C++ and Asio... I just come from here Asio difference between prefer, require and make_work_guard [LINK] . I am trying to make a "dummy work" for my io_context. It is really confusing to a beginner who just wants to make a simple "UDP socket". The ancient book from Packt and Youtube ( [this video] ) tutorial tells me to use "work()", the old document tell me to use a much more complex class called "excutor_work_guard", and the new fashion document just tell me to use something extremely unreadable "require()"... Could I just use "make_work_guard()" and forget about everything else? Sorry for my English...
Cites sehe · 2022-03 · Stack Overflow · on “Asio difference between work(), require() and make_work_guard()”
As you state yourself, this is a full duplicate of the linked question. The answer there answers every point you make here. The ancient book from Packt and Youtube ( [this video] ) tutorial tells me to use "work()" I have bad experiences with Packt books on Asio¹. Regardless, there was never a function work() . You probably meant boost::asio::io_service svc; boost::asio::io_service::work work(svc); The newer interface is indeed boost::asio::io_context ioc; auto work = make_work_guard(ioc); That's it. and the new fashion document just tell me to use something extremely unreadable "require()"... I have never (ever) seen that anywhere. Can you point me to the place where you found that? In fact, as
Cites LCsa · 2022-10 · Stack Overflow · on “Creating server-side GUI (Qt) on every client-connect: unresponsive GUI”
I want to create a C++ multi-client server ( asio ) application that creates a server-side Qt GUI instance for every established connection to a client. The GUI will be associated with the connection. Problem: The created GUI instances remain unresponsive. Removing a recursive call (shown below) in the asio::async_accept handler solves that, but obviously doesn't allow another client to connect. The design is based on OneLoneCoder's Networking tutorial [this video] The MWE does not include error handling, resource management etc... MWE Header file communication.h : #ifndef COMMUNICATION_H #define COMMUNICATION_H #include <iostream> #include <string> #include "dep/3rdparty/asio/asio.hpp" #include