@@ -12,7 +12,8 @@ using namespace lsl;
1212using namespace lslboost ::asio;
1313
1414udp_server::udp_server (const stream_info_impl_p &info, io_context &io, udp protocol)
15- : info_(info), io_(io), socket_(new udp::socket(io)), time_services_enabled_(true ) {
15+ : info_(info), io_(io), socket_(std::make_shared<udp::socket>(io)),
16+ time_services_enabled_(true ) {
1617 // open the socket for the specified protocol
1718 socket_->open (protocol);
1819
@@ -29,7 +30,8 @@ udp_server::udp_server(const stream_info_impl_p &info, io_context &io, udp proto
2930
3031udp_server::udp_server (const stream_info_impl_p &info, io_context &io, const std::string &address,
3132 uint16_t port, int ttl, const std::string &listen_address)
32- : info_(info), io_(io), socket_(new udp::socket(io)), time_services_enabled_(false ) {
33+ : info_(info), io_(io), socket_(std::make_shared<udp::socket>(io)),
34+ time_services_enabled_(false ) {
3335 ip::address addr = ip::make_address (address);
3436 bool is_broadcast = addr == ip::address_v4::broadcast ();
3537
@@ -127,7 +129,8 @@ void udp_server::handle_receive_outcome(error_code err, std::size_t len) {
127129 if (info_->matches_query (query)) {
128130 // query matches: send back reply
129131 udp::endpoint return_endpoint (remote_endpoint_.address (), return_port);
130- string_p replymsg (new std::string ((query_id += " \r\n " ) += shortinfo_msg_));
132+ string_p replymsg (
133+ std::make_shared<std::string>((query_id += " \r\n " ) += shortinfo_msg_));
131134 socket_->async_send_to (lslboost::asio::buffer (*replymsg), return_endpoint,
132135 lslboost::bind (&udp_server::handle_send_outcome, shared_from_this (),
133136 replymsg, placeholders::error));
@@ -147,7 +150,7 @@ void udp_server::handle_receive_outcome(error_code err, std::size_t len) {
147150 std::ostringstream reply;
148151 reply.precision (16 );
149152 reply << " " << wave_id << " " << t0 << " " << t1 << " " << lsl_clock ();
150- string_p replymsg (new std::string (reply.str ()));
153+ string_p replymsg (std::make_shared<std:: string> (reply.str ()));
151154 socket_->async_send_to (lslboost::asio::buffer (*replymsg), remote_endpoint_,
152155 lslboost::bind (&udp_server::handle_send_outcome, shared_from_this (),
153156 replymsg, placeholders::error));
0 commit comments