我试图接收到一个queue->buffer
地方queue->buffer
char * buffer = new char[1024]
void AsyncConnection::BeginReceive(){
m_socket.async_read_some(boost::asio::buffer(&queue->GetBuffer()[queue->GetOffset()], queue->GetBufferLength() - queue->GetOffset()), boost::bind(&AsyncConnection::EndReceive, shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
}
并使用此方法将字节数组转换为十六进制:-
#include <iomanip>
void output_hex(std::ostream& out, char* buf, int len) {
for (int i = 0; i < len; i++)
out << std::noshowbase
<< std::hex
<< std::setfill('0')
<< std::setw(2)
<< static_cast<int> (buf[i])
<< " ";
out << std::dec << std::endl;
}
输出如下所示:-
17 ffffff84 04 65 ffffff83 45 fffffff3 ffffffe2 ffffffdf 0f 33 ffffffa5 14 fffff
fcb 75 6f 5f ffffff89 ffffffb0 22 27 fffffffe ffffffeb fffffff2 ffffffef ffffffe
8 53 40 ffffffbe 18 ffffffa6 ffffff84 67 53 33 ffffffd6 ffffffa6 16 ffffff81 fff
fffe0 ffffffd9 05 35 ffffffab 16 ffffffc1 7f 6d 59 ffffff87 ffffffba 20
这是错的那些ffffff
是错的!也许有某种错误的分配?!