I made a server through the drilling network and worked well, but when I store clients connecting to it on std :: map, then loop the whole map and get from them, it gives me a segmentation error, heres backtrace (gdb):
Program received signal SIGSEGV, Segmentation fault.
boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_sock
t_service<boost::asio::ip::tcp> >::read_some<boost::asio::mutable_buffers_1>
(this=0x153fe48, buffers=@0x22fa48, ec=@0x22fa50)
at D:/Dev-Cpp/include/boost/asio/detail/win_iocp_socket_service.hpp:294
294 {
(gdb) bt
ocket_service<boost::asio::ip::tcp> >::read_some<boost::asio::mutable_buffers_1
(this=0x153fe48, buffers=@0x22fa48, ec=@0x22fa50)
at D:/Dev-Cpp/include/boost/asio/detail/win_iocp_socket_service.hpp:294
at D:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bi
s/basic_string.h:1456
(gdb)
my client.cpp:
#include "client.h"
#include <iostream>
#include <boost/array.hpp>
Client::Client(boost::asio::ip::tcp::socket* _sock)
: sock(_sock)
{
}
Client::~Client()
{
}
void Client::send(const std::string& msg)
{
boost::asio::write(*sock, boost::asio::buffer(msg, msg.length()));
}
std::string Client::receive()
{
boost::array<char, 1024> buffer;
boost::system::error_code err;
sock->read_some(boost::asio::buffer(buffer), err);
if (err == boost::asio::error::eof)
return std::string();
return std::string(buffer.data());
}
What can i do with this?
user502230
source
share