本文整理汇总了C++中system::error_code::message方法的典型用法代码示例。如果您正苦于以下问题:C++ error_code::message方法的具体用法?C++ error_code::message怎么用?C++ error_code::message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类system::error_code
的用法示例。
在下文中一共展示了error_code::message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throw_system_error
inline
void throw_system_error(system::error_code ec)
{
if (ec)
{
if (ec.category() == runtime_error_category())
{
throw runtime_system_error(ec, ec.message());
}
if (ec.category() == logic_error_category()) {
throw logic_system_error(ec, ec.message());
}
throw system::system_error(ec, ec.message());
}
}
示例2: on_empty_buffer
void CProtocol::on_empty_buffer(const system::error_code& error, std::size_t bytes) {
empty_buffer_[bytes] = 0;
std::string reply(empty_buffer_);
if (bytes > 0)
std::cout << "on_empty_buffer: " << bytes << " " << reply << std::endl;
buffer_empty_ = true;
if(error != 0)
std::cout << "on_empty_buffer error: " << error << " message: "<< error.message() << std::endl;
}
示例3: handle_read
void Peer::handle_read(const system::error_code& e, std::size_t bytes_transferred) {
log_trace("args error: %s, bytes: %d", e.message(), bytes_transferred);
if (!e) {
_activity = true;
string rx;
for(int i = 0; i < bytes_transferred; i++)
rx.push_back(_buffer[i]);
vRecv += rx;
// Now call the parser:
bool fRet = false;
loop {
boost::tuple<boost::tribool, CDataStream::iterator> parser_result = _msgParser.parse(_chain, _message, vRecv.begin(), vRecv.end());
tribool result = get<0>(parser_result);
vRecv.erase(vRecv.begin(), get<1>(parser_result));
if (result) {
if (_messageHandler.handleMessage(this, _message) ) fRet = true;
}
else if (!result) {
log_warn("Peer %s sending bogus - disconnecting", addr.toString());
_peerManager.post_stop(shared_from_this());
}// continue; // basically, if we get a false result, we should consider to disconnect from the Peer!
else
break;
}
// now if fRet is true, something were processed by the filters - we want to send to the peers / we check for which vSends cointains stuff and the we run
if (fRet && nVersion > 0) {
// first reply
reply();
// then trickle
Peers peers = _peerManager.getAllPeers();
size_t rand = GetRand(peers.size());
for (Peers::iterator peer = peers.begin(); peer != peers.end(); ++peer)
if(rand-- == 0) {
(*peer)->trickle();
break;
}
// then broadcast
for (Peers::iterator peer = peers.begin(); peer != peers.end(); ++peer)
(*peer)->broadcast();
// now write to the peers with non-empty vSend buffers
for (Peers::iterator peer = peers.begin(); peer != peers.end(); ++peer) {
(*peer)->flush();
}
}
// then wait for more data
_socket.async_read_some(buffer(_buffer), boost::bind(&Peer::handle_read, shared_from_this(), asio::placeholders::error, asio::placeholders::bytes_transferred));
// async_read(_socket, _recv, boost::bind(&Peer::handle_read, shared_from_this(), asio::placeholders::error, asio::placeholders::bytes_transferred));
}
示例4: OnSend
void CTcpSocket::OnSend( const system::error_code &ec, size_t nByteTransferred )
{
if (ec)
{
LOGError(ec.message().c_str());
DoClose();
return ;
}
m_wSendLength -= nByteTransferred;
if (m_wSendLength > 0)
{
LOGError("理论来讲,这里是进不来的!");
// 理论来讲,这里是进不来的。
memcpy(m_szSendBuffer, m_szSendBuffer + nByteTransferred, m_wSendLength);
// 发送数据
m_pSock->async_write_some(buffer(m_szSendBuffer, m_wSendLength),
bind(&CTcpSocket::OnSend, this, placeholders::error, placeholders::bytes_transferred));
}
else if (0 == m_wSendLength)
{
// 拷贝数据
std::list<MsgData>::iterator it = m_listMsgData.begin();
for (; it!=m_listMsgData.end(); )
{
MsgData &msgData = (*it);
if (MAX_SEND_BUFFER_LENGTH - m_wSendLength >= msgData.wLength)
{
USHORT *pPacketLength = (USHORT *)m_szSendBuffer;
*pPacketLength = msgData.wLength;
m_wSendLength += sizeof(USHORT);
memcpy(m_szSendBuffer + m_wSendLength, msgData.szData, msgData.wLength);
m_wSendLength += msgData.wLength;
it = m_listMsgData.erase(it);
}
else
{
break;
}
}
// 发送数据
m_pSock->async_write_some(buffer(m_szSendBuffer, m_wSendLength),
bind(&CTcpSocket::OnSend, this, placeholders::error, placeholders::bytes_transferred));
}
else
{
LOGError("异常错误!");
}
}
示例5: handle_write
void Proxy::handle_write(const system::error_code& e, size_t bytes_transferred) {
if (!e) {
// ignore
}
else if (e != error::operation_aborted) {
log_error("Proxy write error %s, disconnecting...", e.message());
// forward the error to the connection handler callback
_connection_handler(e);
}
}
示例6: Handle_Write_HTTP_Request
void Sony_Remote_Camera_Implementation::Handle_Write_HTTP_Request(bool mode_liveview, bool event_thread, const system::error_code& err) {
asio::ip::tcp::socket& s = mode_liveview ? socket_liveview : (event_thread ? socket_event_listener : socket_options);
asio::streambuf& buf = mode_liveview ? tcp_response_liveview : (event_thread ? tcp_response_events : tcp_response_options);
if (!err) {
boost::asio::async_read_until(s, buf, "\r\n",
boost::bind(&Sony_Remote_Camera_Implementation::Handle_Read_Status_Line, this, mode_liveview, event_thread,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
} else {
throw(ios_base::failure(err.message()));
}
}
开发者ID:ernest-galbrun,项目名称:sony_remote_camera_cpp_drivers,代码行数:11,代码来源:sony_remote_camera_implementation.cpp
示例7: callback
void callback(system::error_code ec) {
std::cout << __PRETTY_FUNCTION__ << "\n";
if (ec != asio::error::operation_aborted) {
std::cout << " - continuing wait - keeps the object alive (as it should)\n";
tim.expires_from_now(posix_time::seconds(2));
tim.async_wait(bind(&MySessionThing::callback, shared_from_this(), asio::placeholders::error));
}
std::cout << " - " << ec.message() << ": exiting handler - also implicitly releases the lock on MySessionThing\n";
// only if the new async_wait has *not* been posted, this will cause the destructor to run
}
示例8: on_send
void Client::on_send(system::error_code err, size_t bytesTransferred, uint8_t* p, size_t packetLength)
{
unused_parameter(bytesTransferred);
unused_parameter(packetLength);
delete[] p;
if(err)
return Transmitter::disconnect(format("Send failed: %2%") % err.message());
assert(bytesTransferred == packetLength);
}
示例9: handle_accept
void TcpServer::handle_accept(const system::error_code& error)
{
if(!acceptor_.is_open())
{
debug->warning(1, type, "TCP Socket, port %i - acceptor is not open!", port);
return;
}
if(!error)
new_connection->start();
else
debug->warning(1, type, "TCP Socket, port %i - error: %s, error code: %i", error.message().c_str(), error.value());
start_accept();
}
示例10: read_callback
// read_callback - passed information about bytes in read_buf to handle_by_protocol method.
void read_callback(size_t bytes_transferred,const system::error_code& error)
{
if (error || !bytes_transferred)
{
if(log_level) std::cerr << "read callback error:" << error << ": " << error.message() << std::endl;
return;
}
long packet_found = data_received(read_buf,bytes_transferred);
if(!packet_found) {
initiate_read();
}
}
示例11: on_receive_reply
void CProtocol::on_receive_reply(const system::error_code& error, std::size_t bytes) {
cmd_response_[bytes] = 0;
std::string reply(cmd_response_);
std::cout << "<- " << reply << std::endl;
if (bytes != active_command_.expected_sizeof_reply())
return;
if(running_)
active_command_.handle_reply(reply);
// signal command finished
command_ready_ = true;
if(error != 0)
std::cout << "on_receive_reply error: " << error << " message: "<< error.message() << " bytes: " << bytes << std::endl;
}
示例12: accept_handler
//接受新的请求
void accept_handler(const system::error_code& e, sock_ptr s)
{
if (e)
{
cout << e.message() << endl;
return;
}
//添加
clientSock.push_back(s);
cout << "client:" << s->remote_endpoint().address() << " port:" << s->remote_endpoint().port() << endl;
s->async_write_some(buffer("hello asio"), boost::bind(&server::write_handle, this, boost::asio::placeholders::error, s));
//继续异步请求
start();
}
示例13: on_recv
void on_recv(const system::error_code &error)
{
if(error)
{
cerr << "recv error: "<< error.message() << "\n";
close();
return;
}
else
{
cerr << _buf ;
}
_stream.async_read_some(buffer(_buf,sizeof(_buf)),
boost::bind(&OCS_Stream::on_recv,this,placeholders::error));
}
示例14: handle_proxy_connect
void Proxy::handle_proxy_connect(const system::error_code& e) {
// write the
if (!e && _socket->is_open()) { // connected successfully to the proxy server
Socks4::Request req(Socks4::Request::connect, _endpoint, "");
async_write(*_socket, req.buffers(), boost::bind(&Proxy::handle_write, this, asio::placeholders::error, asio::placeholders::bytes_transferred));
// this async_read returns only when the buffer has been filled
async_read(*_socket, _reply.buffers(), boost::bind(&Proxy::handle_proxy_reply, this, asio::placeholders::error, asio::placeholders::bytes_transferred));
}
else {
log_error("Failed connect to proxy server: \"%s\" to: %s", e.message(), lexical_cast<string>(_server));
_connection_handler(e);
}
}
示例15: check_activity
void Peer::check_activity(const system::error_code& e) {
if (!e) {
if(!_activity)
_peerManager.post_stop(shared_from_this());
else {
_activity = false;
_suicide.expires_from_now(posix_time::seconds(_suicide_timeout)); // 90 minutes of activity once we have started up
_suicide.async_wait(boost::bind(&Peer::check_activity, this, asio::placeholders::error));
}
}
else if (e != error::operation_aborted) {
log_info("Boost deadline timer error in Peer: %s\n", e.message().c_str());
}
// we ignore abort errors - they are generated due to timer cancels
}