File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -86,10 +86,9 @@ namespace cs_impl {
86
86
87
87
std::string receive (std::size_t maximum)
88
88
{
89
- buffer<> buff_guard (maximum + 1 );
90
- char *buff = buff_guard.get ();
91
- buff[sock.receive (asio::buffer (buff, maximum))] = ' \0 ' ;
92
- return buff;
89
+ buffer<> buff (maximum);
90
+ std::size_t actually = sock.receive (asio::buffer (buff.get (), maximum));
91
+ return std::string (buff.get (), actually);
93
92
}
94
93
95
94
void send (const std::string &s)
@@ -151,10 +150,9 @@ namespace cs_impl {
151
150
152
151
std::string receive_from (std::size_t maximum, udp::endpoint &ep)
153
152
{
154
- buffer<> buff_guard (maximum + 1 );
155
- char *buff = buff_guard.get ();
156
- buff[sock.receive_from (asio::buffer (buff, maximum), ep)] = ' \0 ' ;
157
- return buff;
153
+ buffer<> buff (maximum);
154
+ std::size_t actually = sock.receive_from (asio::buffer (buff.get (), maximum), ep);
155
+ return std::string (buff.get (),actually);
158
156
}
159
157
160
158
void send_to (const std::string &s, const udp::endpoint &ep)
You can’t perform that action at this time.
0 commit comments