From: Mohammad Nejati [ashtum] (ashtumashtum_at_[hidden])
Date: 2024-04-29 18:48:18


You just need to disable automatic flushing:

s1 << std::nounitbuf;
// or
s1.unsetf(std::ios_base::unitbuf);

https://en.cppreference.com/w/cpp/io/manip/unitbuf

By the way you can call connect directly on s1 no need to take a reference.