本文整理汇总了C++中boost::system::error_code类的典型用法代码示例。如果您正苦于以下问题:C++ error_code类的具体用法?C++ error_code怎么用?C++ error_code使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了error_code类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: handleAcceptError
void Server::handleAcceptError(const boost::system::error_code& ec)
{
std::cout << "ERROR error reason:" << ec.value() << " " << ec.message() << std::endl;
stopAccept();
}
开发者ID:longshadian,项目名称:estl,代码行数:5,代码来源:Server.cpp
示例2: handle_read_head
void SSLSession::handle_read_head(const boost::system::error_code& error, size_t bytes_transferred, IMessage* req)
{
if (error)
{
gFileLog::instance().Log("SSLSession 读包头失败, 错误代码:" + boost::lexical_cast<std::string>(error.value()) + ", 错误消息:" + error.message());
close();
return;
}
if (bytes_transferred != req->GetMsgHeaderSize())
{
gFileLog::instance().Log("SSLSession 读包头失败,需要读:" + boost::lexical_cast<std::string>(req->GetMsgHeaderSize()) + ", 实际读:" + boost::lexical_cast<std::string>(bytes_transferred) );
close();
return;
}
if (!req->DecoderMsgHeader())
{
gFileLog::instance().Log("SSLSession 解码包头失败");
close();
return;
}
boost::asio::async_read(socket_,
boost::asio::buffer(req->GetMsgContent(), req->GetMsgContentSize()),
boost::asio::transfer_all(),
strand_.wrap(
bind(&SSLSession::handle_read_msg, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, req)
)
);
}
开发者ID:firememory,项目名称:Whatway,代码行数:35,代码来源:SSLSession.cpp
示例3: onSend
void UdpClient::onSend( const string& message, const boost::system::error_code& error,
std::size_t bytesTransferred )
{
OutputDebugStringA( ( error.message() + "\n" ).c_str() );
}
开发者ID:calebjohnston,项目名称:Cinder-Network,代码行数:5,代码来源:UdpClient.cpp
示例4: output_error
void server_conn::output_error( std::string err_msg, const boost::system::error_code &e )
{
cerr<<err_msg<<", error message: "<<e.message()<<endl;
}
开发者ID:cyber4ron,项目名称:mmo-server,代码行数:4,代码来源:connection_server.cpp
示例5: lg
void smtp_client::connection::got_response(std::string resp, boost::system::error_code ec, size_t bytes) {
if (ec) {
NSC_LOG_ERROR("smtp failure in reading: " + ec.message());
boost::lock_guard<boost::mutex> lg(sc->m);
if (cur)
sc->ready.push_back(cur);
sc->active_connection.reset();
return;
}
std::string line;
line.reserve(bytes);
for (size_t i = 0; i < bytes; i++)
line += char(readbuf.sbumpc());
resp += line;
if (line.length() >= 4 && line[3] == '-') {
boost::asio::async_read_until(serv, readbuf, "\r\n", boost::bind(&connection::got_response, shared_from_this(), resp, _1, _2));
return;
}
NSC_DEBUG_MSG("smtp read " + resp);
bool broken_resp = resp.empty() || !('2' <= resp[0] && resp[0] <= '5') || (resp[0] == '3' && (state != DATA || resp.substr(0,3) != "354"));
// FIXME deferral / drop-on-the-floor notifications
if (broken_resp || resp[0] == '4')
{
boost::lock_guard<boost::mutex> lg(sc->m);
if (cur)
sc->deferred.push_back(cur);
}
if (broken_resp || state == QUIT) {
NSC_LOG_ERROR("smtp terminating");
boost::lock_guard<boost::mutex> lg(sc->m);
sc->active_connection.reset();
return;
}
if ((resp[0] == '4' || resp[0] == '5' || state == DATA_354) && (resp.substr(0,3) != "502" || state != EHLO)) {
cur.reset();
if (sc->ready.empty() || state <= RSET) {
state = QUIT;
send_line("QUIT");
} else {
state = RSET;
send_line("RSET");
}
return;
}
assert(!resp.empty());
switch (state) {
case BANNER:
assert(resp[0] == '2');
state = EHLO;
send_line("EHLO " + config["canonical-name"]);
break;
case EHLO:
if (resp.substr(0,3) == "502")
{
state = HELO;
send_line("HELO" + config["canonical-name"]);
break;
}
assert(resp[0] == '2');
/* passthrough */
case HELO:
case RSET:
assert(resp[0] == '2');
assert(!cur);
{
boost::lock_guard<boost::mutex> lg(sc->m);
if (sc->ready.empty())
{
state = QUIT;
send_line("QUIT");
break;
}
cur = sc->ready.front();
sc->ready.pop_front();
}
assert(cur);
state = MAIL_FROM;
send_line("MAIL FROM: <" + cur->sender + ">");
break;
case MAIL_FROM:
assert(resp[0] == '2');
assert(cur);
state = RCPT_TO;
send_line("RCPT TO: <" + cur->recipient + ">");
break;
case RCPT_TO:
assert(resp[0] == '2');
assert(cur);
state = DATA;
//.........这里部分代码省略.........
开发者ID:0000-bigtree,项目名称:nscp,代码行数:101,代码来源:smtp.cpp
示例6: error_callback
inline void error_callback(boost::system::error_code e)
{
std::cerr << "System error: " << e.message() << std::endl;
std::exit(1);
}
开发者ID:Palmik,项目名称:bob,代码行数:5,代码来源:main.cpp
示例7: request_failed
void HTTPClient::request_failed(const boost::system::error_code& err)
{
logger << "HTTPClient Request failed: " << err.message() << ". Retrying." << std::endl;
abort_request();
}
开发者ID:dot-Sean,项目名称:Helix,代码行数:5,代码来源:http_client.cpp
示例8: handleRead
void ClientConnection::handleRead( const boost::system::error_code& error )
{
if ( error == 0)
{
// invoke a thread to handle the message
boost::thread worker( &ClientConnection::handleReadInThread,
this,
message );
// back to listen
waitForData();
}
else
{
// if an error occurs, close the connection
std::stringstream stream;
stream << "ClientConnection (" << technicalId << ") > handleRead call with error code: " << error.value() << " --> " << error.message();
AsyncLogger::getInstance()->log( stream.str() );
connectionManager->closeConnection( shared_from_this() );
}
}
开发者ID:vorkostil,项目名称:vsGame,代码行数:22,代码来源:ClientConnection.cpp
示例9: future_error
future_error(boost::system::error_code ec)
: logic_error(ec.message())
, ec_(ec)
{}
开发者ID:cokeboL,项目名称:fibio,代码行数:4,代码来源:exceptions.hpp
示例10: handle_error
/* Some error occured at lower levels. Logging it and deactivating the current session seems legit.
*/
void ServerProtocolDispatcher::handle_error(
boost::system::error_code error)
{
std::cout << "ServerProtocolDispatcher::handle_error: " << error.message() << std::endl;
_active = false;
}
开发者ID:C3MA,项目名称:fullcircle,代码行数:8,代码来源:server_protocol_dispatcher.cpp
示例11: handle_write_msg
void SSLSession::handle_write_msg(const boost::system::error_code& error, size_t bytes_transferred, IMessage* resp)
{
if (error)
{
gFileLog::instance().Log("SSLSession 写包内容失败, 错误代码:" + boost::lexical_cast<std::string>(error.value()) + ", 错误消息:" + error.message());
close();
return;
}
if (bytes_transferred != resp->GetMsgContentSize())
{
gFileLog::instance().Log("SSLSession 写包内容失败 需要写:" + boost::lexical_cast<std::string>(resp->GetMsgContentSize()) + ", 实际写:" + boost::lexical_cast<std::string>(bytes_transferred) );
close();
return;
}
// 存入日志队列
resp->SetSendTime();
gFileLogManager::instance().push(resp->log);
gDistributedLogManager::instance().push(resp->log);
/*
if (resp->GetMsgHeader()->FunctionNo == 0)
{
// 心跳功能不写日志
}
else
{
}
*/
// 删除应答包
resp->destroy();
}
开发者ID:firememory,项目名称:Whatway,代码行数:40,代码来源:SSLSession.cpp
示例12: handle_write_head
void SSLSession::handle_write_head(const boost::system::error_code& error, size_t bytes_transferred, IMessage* resp)
{
if (error)
{
gFileLog::instance().Log("SSLSession 写包头失败,错误代码:" + boost::lexical_cast<std::string>(error.value()) + ", 错误消息:" + error.message());
close();
return;
}
if (bytes_transferred != resp->GetMsgHeaderSize())
{
gFileLog::instance().Log("SSLSession 写包头失败 需要写:" + boost::lexical_cast<std::string>(resp->GetMsgHeaderSize()) + ", 实际写:" + boost::lexical_cast<std::string>(bytes_transferred) );
close();
return;
}
try
{
boost::asio::async_write(socket_,
boost::asio::buffer(resp->GetMsgContent(), resp->GetMsgContentSize()),
boost::asio::transfer_all(),
strand_.wrap(
bind(&SSLSession::handle_write_msg, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, resp)
)
);
}
catch(std::exception& e)
{
std::string expMsg = e.what();
gFileLog::instance().Log("SSLSession handle_write_head exp: " + expMsg);
}
}
开发者ID:firememory,项目名称:Whatway,代码行数:36,代码来源:SSLSession.cpp
示例13: handle_read_msg
void SSLSession::handle_read_msg(const boost::system::error_code& error, size_t bytes_transferred, IMessage* req)
{
if (error)
{
gFileLog::instance().Log("SSLSession 读包内容失败, 错误代码:" + boost::lexical_cast<std::string>(error.value()) + ", 错误消息:" + error.message());
close();
return;
}
if (bytes_transferred != req->GetMsgContentSize())
{
gFileLog::instance().Log("SSLSession 读包内容失败 需要读:" + boost::lexical_cast<std::string>(req->GetMsgContentSize()) + ", 实际读:" + boost::lexical_cast<std::string>(bytes_transferred) );
close();
return;
}
// 设置接收到的时间
req->SetRecvTime();
queue_.push(req);
read();
}
开发者ID:firememory,项目名称:Whatway,代码行数:29,代码来源:SSLSession.cpp
示例14: peer
boost::system::error_code Connector::connect(
SocketType & peer1,
NetName const & netname,
boost::system::error_code & ec)
{
typedef typename SocketType::protocol_type::socket socket;
typedef typename socket::endpoint_type endpoint_type;
socket & peer(peer1); // we should use the real socket type, not the child type
if (netname.is_digit()) {
return connect(peer, netname.endpoint(), ec);
}
if (!started_) {
canceled_ = canceled_forever_;
stat_.reset();
connect_started_ = false;
boost::asio::detail::mutex::scoped_lock lock(mutex_);
if (canceled_) {
ec = boost::asio::error::operation_aborted;
canceled_ = false;
} else {
lock.unlock();
resolver_iterator_ = resolver_.resolve(netname, ec);
lock.lock();
}
stat_.resolve_time = stat_.elapse();
if (ec) {
return ec;
} else if (canceled_) {
canceled_ = false;
return ec = boost::asio::error::operation_aborted;
}
started_ = true;
}
ResolverIterator end;
for (; resolver_iterator_ != end; ++resolver_iterator_) {
if (!connect_started_) {
Endpoint const & e = *resolver_iterator_;
{
boost::asio::detail::mutex::scoped_lock lock(mutex_);
if (canceled_) {
ec = boost::asio::error::operation_aborted;
canceled_ = false;
} else {
if (peer.is_open()) {
peer.close(ec);
}
boost::asio::socket_base::non_blocking_io cmd1(non_block_);
#ifndef UNDER_CE
boost::asio::socket_base::receive_time_out cmd2(time_out_);
#endif
ec || peer.open(endpoint_type(e).protocol(), ec)
|| peer.io_control(cmd1, ec)
#ifndef UNDER_CE
|| peer.set_option(cmd2, ec)
#endif
;
}
}
if (ec) {
break;
}
LOG_TRACE("[connect] try server, ep: " << e.to_string());
start_connect(peer, e, ec);
} else {
ec = boost::asio::error::would_block;
}
if (ec == boost::asio::error::would_block) {
pool_connect(peer, ec);
}
if (ec != boost::asio::error::would_block) {
if (!ec) {
post_connect(peer, ec);
} else {
boost::system::error_code ec1;
post_connect(peer, ec1);
}
}
if (!ec || ec == boost::asio::error::would_block || canceled_) {
break;
}
LOG_DEBUG("[connect] failed, ep: " <<
resolver_iterator_->to_string() << ",ec: " << ec.message());
} // for
if ((!ec || ec == boost::asio::error::would_block) && canceled_) {
ec = boost::asio::error::operation_aborted;
}
if (ec != boost::asio::error::would_block) {
stat_.connect_time = stat_.elapse();
started_ = false;
canceled_ = false;
}
return ec;
}
开发者ID:huangyt,项目名称:MyProjects,代码行数:95,代码来源:Connector.hpp
示例15: AddServer
/*
* Connects to a server
* - on success: adds all server related elements
* - on failure: retries
*/
void Communication::AddServer(const boost::system::error_code& error,
boost::shared_ptr<boost::asio::ip::tcp::socket> soc,
boost::asio::ip::tcp::endpoint endpoint,
boost::shared_ptr<std::string> server,
boost::shared_ptr<std::string> ip,
boost::shared_ptr<std::string> port)
{
// remote host is now connected
if (!error)
{
// lock any "sockets_.size()" usage/modification
com_mutex_.lock();
// add a pub, along with all related pub elements
sockets_.push_back(soc);
servers_.push_back(server);
boost::shared_ptr< boost::array<char, 30> > new_buf_ptr(new boost::array<char, 30>);
new_buf_ptr->assign(0);
buf_.push_back(new_buf_ptr);
is_reading_.push_back(false);
Connection new_server;
new_server.pub_id = *server;
new_server.ip = *ip;
new_server.port = *port;
connections_.push_back(new_server);
// report successful connection
out_mutex_.lock();
std::cout << "\n[" << boost::this_thread::get_id()
<< "] >> Connection to " << *server
<< " at " << endpoint << " succeded \n" << std::endl;
out_mutex_.unlock();
// let the read operations begin/continue
is_pending_add_ = false;
pending_add_condition_.notify_one();
// unlock any "sockets_.size()" usage/modification
com_mutex_.unlock();
// inform on first connection
if (sockets_.size() == 1)
{
pending_first_condition_->notify_one();
}
}
// remote host is not connected yet
else if (error.message() == "Connection refused")
{
// try again
usleep(100000);
soc.reset(new boost::asio::ip::tcp::socket(*io_service_));
soc->async_connect(endpoint,
boost::bind(&Communication::AddServer,
this,
boost::asio::placeholders::error(),
soc,
endpoint,
server,
ip,
port));
}
else // report error
{
out_mutex_.lock();
std::cout << "[" << boost::this_thread::get_id()
<< "] Error: " << error.message() << std::endl;
out_mutex_.unlock();
}
}
开发者ID:Dim-Sal,项目名称:short,代码行数:77,代码来源:communication.cpp
示例16: handleWrite
void ClientConnection::handleWrite( const boost::system::error_code& error )
{
// if an error occurs, close the connection
if ( error != 0 )
{
std::stringstream stream;
stream << "ClientConnection (" << technicalId << ") > handleWrite call with error code: " << error.value() << " --> " << error.message();
AsyncLogger::getInstance()->log( stream.str() );
connectionManager->closeConnection( shared_from_this() );
}
}
开发者ID:vorkostil,项目名称:vsGame,代码行数:12,代码来源:ClientConnection.cpp
示例17: handle_error
void handle_error(boost::system::error_code const& error, int expected_error, std::string const& expected_message)
{
BOOST_CHECK_EQUAL(expected_error, error.value());
BOOST_CHECK_EQUAL(expected_message, error.message());
}
开发者ID:bartvercammen,项目名称:kafka-cpp,代码行数:5,代码来源:producer_tests.cpp
示例18: SentHTTPFailed
void HTTPProxyHandler::SentHTTPFailed(const boost::system::error_code & ecode)
{
if (!ecode)
Terminate();
else
{
LogPrint (eLogError,"--- HTTP Proxy Closing socket after sending failure because: ", ecode.message ());
Terminate();
}
}
开发者ID:7histle,项目名称:i2pd,代码行数:10,代码来源:HTTPProxy.cpp
示例19: OnError
void RFXComTCP::OnError(const boost::system::error_code& error)
{
_log.Log(LOG_ERROR, "RFXCOM: Error: %s", error.message().c_str());
}
开发者ID:htlinux,项目名称:domoticza,代码行数:4,代码来源:RFXComTCP.cpp
示例20: NSC_LOG_ERROR
void smtp_client::connection::connected(boost::asio::ip::tcp::resolver::iterator iter, boost::system::error_code ec) {
if (ec) {
NSC_LOG_ERROR("smtp failed to connect to " + iter->endpoint().address().to_string() + ": " + ec.message());
iter++;
resolved(boost::system::error_code(), iter);
return;
}
NSC_DEBUG_MSG("smtp connected to " + iter->endpoint().address().to_string());
state = BANNER;
async_read_response();
}
开发者ID:0000-bigtree,项目名称:nscp,代码行数:12,代码来源:smtp.cpp
注:本文中的boost::system::error_code类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论