本文整理汇总了C++中boost::system::error_code::category方法的典型用法代码示例。如果您正苦于以下问题:C++ error_code::category方法的具体用法?C++ error_code::category怎么用?C++ error_code::category使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::system::error_code
的用法示例。
在下文中一共展示了error_code::category方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m_onError
void
onResolveSuccess(const boost::system::error_code& error,
BoostResolver::iterator remoteEndpoint,
const shared_ptr<Resolver>& self)
{
m_scheduler.cancelEvent(m_resolveTimeout);
if (error)
{
if (error == boost::system::errc::operation_canceled)
{
return;
}
return m_onError("Remote endpoint hostname or port cannot be resolved: " +
error.category().message(error.value()));
}
BoostResolver::iterator end;
for (; remoteEndpoint != end; ++remoteEndpoint)
{
IpAddress address(EndPoint(*remoteEndpoint).address());
if (m_addressSelector(address))
{
return m_onSuccess(address);
}
}
m_onError("No endpoint matching the specified address selector found");
}
示例2: equivalent
bool
equivalent (boost::system::error_code const& error,
int ev) const noexcept override
{
return error.value() == ev &&
&error.category() == this;
}
示例3: m_onError
void
onResolveSuccess(const boost::system::error_code& error,
typename resolver::iterator remoteEndpoint,
const shared_ptr<Resolver>& self)
{
scheduler::cancel(m_resolveTimeout);
if (error)
{
if (error == boost::system::errc::operation_canceled)
return;
return m_onError("Remote endpoint hostname or port cannot be resolved: " +
error.category().message(error.value()));
}
typename resolver::iterator end;
for (; remoteEndpoint != end; ++remoteEndpoint)
{
if (m_addressSelector(typename Protocol::endpoint(*remoteEndpoint).address()))
return m_onSuccess(*remoteEndpoint);
}
m_onError("No endpoint matching the specified address selector found");
}
示例4: reactor_operation
// Record a reactor-based operation that is associated with a handler.
static void reactor_operation(const tracked_handler& h,
const char* op_name, const boost::system::error_code& ec)
{
std::printf(
"Performed operation %s.%s for native_handle = %" PRIuMAX
", ec = %s:%d\n", h.object_type_, op_name, h.native_handle_,
ec.category().name(), ec.value());
}
示例5: handle_data_receive
void OptiTrackNatNetClient::handle_data_receive(const boost::system::error_code& ec,
std::size_t bytes_transferred)
{
if (ec)
{
serr << ec.category().name() << " ERROR while receiving data from " << recv_data_endpoint << sendl;
}
else
{
sout << "Received " << bytes_transferred << "b data from " << recv_data_endpoint << sendl;
sPacket& PacketIn = *recv_data_packet;
switch (PacketIn.iMessage)
{
case NAT_MODELDEF:
{
sout << "Received MODELDEF" << sendl;
if (serverInfoReceived)
{
decodeModelDef(PacketIn);
}
else if (!this->serverName.isSet())
{
server_endpoint = recv_data_endpoint;
server_endpoint.port(PORT_COMMAND);
serr << "Requesting server info to " << server_endpoint << sendl;
boost::array<unsigned short, 2> helloMsg;
helloMsg[0] = NAT_PING; helloMsg[1] = 0;
command_socket->send_to(boost::asio::buffer(helloMsg), server_endpoint);
}
break;
}
case NAT_FRAMEOFDATA:
{
sout << "Received FRAMEOFDATA" << sendl;
if (serverInfoReceived)
{
decodeFrame(PacketIn);
}
else if (!this->serverName.isSet())
{
server_endpoint = recv_data_endpoint;
server_endpoint.port(PORT_COMMAND);
serr << "Requesting server info to " << server_endpoint << sendl;
boost::array<unsigned short, 2> helloMsg;
helloMsg[0] = NAT_PING; helloMsg[1] = 0;
command_socket->send_to(boost::asio::buffer(helloMsg), server_endpoint);
}
break;
}
default:
{
serr << "Received unrecognized data packet type: " << PacketIn.iMessage << sendl;
break;
}
}
}
start_data_receive();
}
示例6: FormatError
std::string FormatError(boost::system::error_code err)
{
#if BOOST_OS_WINDOWS
if (err.category() == boost::system::system_category())
err.assign(err.value(), ext::boost_system_utf8_category());
#endif
return FormatErrorImpl(err);
}
示例7: PostConnect
void ClientConnection::PostConnect(const boost::system::error_code& err,
tcp::resolver::iterator endpoint_iterator) {
if (err == asio::error::operation_aborted || err == asio::error::eof
|| connection_state_ == CLOSED) {
return;
}
timer_.cancel();
if (err) {
delete endpoint_;
endpoint_ = NULL;
if (++endpoint_iterator != tcp::resolver::iterator()) {
// Try next endpoint.
CreateChannel();
if (Logging::log->loggingActive(LEVEL_DEBUG)) {
Logging::log->getLog(LEVEL_DEBUG) << "failed: next endpoint"
<< err.message() << "\n";
}
PostResolve(err, endpoint_iterator);
} else {
Reset();
string ssl_error_info;
#ifdef HAS_OPENSSL
if (err.category() == asio::error::ssl_category) {
ssl_error_info = ERR_error_string(ERR_get_error(), NULL);
}
#endif // HAS_OPENSSL
SendError(POSIX_ERROR_EIO,
"could not connect to host '" + server_name_ + ":"
+ server_port_ + "': " + err.message()+" "+ssl_error_info);
}
} else {
// Do something useful.
reconnect_interval_s_ = 1;
next_reconnect_at_ = posix_time::not_a_date_time;
if (Logging::log->loggingActive(LEVEL_DEBUG)) {
Logging::log->getLog(LEVEL_DEBUG) << "connected to "
<< (*endpoint_iterator).host_name() << ":"
<< (*endpoint_iterator).service_name() << endl;
#ifdef HAS_OPENSSL
if (ssl_context_ != NULL) {
Logging::log->getLog(LEVEL_DEBUG) << "Using SSL/TLS version '"
<< ((SSLSocketChannel*) socket_)->ssl_tls_version() << "'." << endl;
}
#endif // HAS_OPENSSL
}
connection_state_ = IDLE;
if (!requests_.empty()) {
SendRequest();
ReceiveRequest();
}
}
}
示例8: isShutdownError
virtual bool isShutdownError(const boost::system::error_code& ec)
{
// boost returns "short_read" when the peer calls SSL_shutdown()
if (ec.category() == boost::asio::error::get_ssl_category() &&
ec.value() == ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ))
{
return true;
}
else
{
return false;
}
}
示例9: HandleAccept
void TCPServer::HandleAccept(SocketP socket,
const boost::system::error_code &ec)
throw() {
if (!ec) {
socket->lowest_layer().set_option(tcp::no_delay(true));
listeners_.push_back(ServerP(
new SocketServer(socket, protocol_,
request_processor_->Duplicate())));
listeners_.back()->Listen();
} else {
LOG4CPLUS_WARN(logger_,
WStringFromUTF8String(
std::string("Error in TCPServer::HandleAccept: ")
+ ec.category().name() + " "
+ boost::lexical_cast<std::string>(ec.value())));
}
StartAccept();
}
示例10: handle_read
void handle_read(const boost::system::error_code& error,
size_t bytes_transferred)
{
if (!error)
{
total_transferred_ += bytes_transferred;
if (total_transferred_ >= data_required)
{
// std::cout << total_transferred_ << std::endl;
return;
}
send_request();
}
else
{
std::cerr << error.value() << std::endl;
std::cerr << error.category().name() << std::endl;
}
}
示例11: on_body
void HttpRequest::on_body(boost::system::error_code const &err, size_t xfer)
{
LogSpam << "HttpRequest::on_body()";
if (!!err)
{
LogWarning << "HttpRequest::on_body(): " << err;
if ((xfer > 0) &&
(err.category() != boost::asio::error::get_misc_category() ||
err.value() != boost::asio::error::eof))
{
error();
return;
}
}
if (debugHttp.enabled())
{
LogNotice << "http on_body" << xfer << "bytes";
}
// got the body!
onBody_();
onBody_.disconnect_all_slots();
onError_.disconnect_all_slots();
}
示例12: handle_read
void MOB_Connection::handle_read(const boost::system::error_code& error, size_t bytes_transferred)
{
if (error)
{
jWARN("WARN: %s\n",error.message().c_str());
jWARN("> category=%s , value=%d\n", error.category().name() ,error.value());
call_MOB_OnDisconnect("socket out error",0);
return;
}
const int iSIZE_m_pDataBuff_Readed = nMOB::BUFFER_SIZE*8;
const int iHEADER_SIZE= sizeof(int);
if((bytes_transferred + m_iReadedSize) >= iSIZE_m_pDataBuff_Readed )
{
DoDisconnect(("socket out if((bytes_transferred+ m_iReadedSize)>= iSIZE_m_pDataBuff_Readed)"),0);
return;
}
memcpy(m_pDataBuff_Readed+m_iReadedSize,m_pDataBuff_Read,bytes_transferred);
m_iReadedSize+=bytes_transferred;
if(m_iReadedSize<= iHEADER_SIZE)
{
_async_read_some();
return;
}
char* pBody = m_pDataBuff_Readed;
int iLengthBody=0;
memcpy(&iLengthBody , pBody, iHEADER_SIZE);
pBody+=iHEADER_SIZE;
if(iLengthBody<=0 || (iLengthBody>=(BUFFER_SIZE-iHEADER_SIZE) ) )
{
DoDisconnect(("socket out error if(iLengthBody<=0 || (iLengthBody>=(BUFFER_SIZE-iHEADER_SIZE) ) )"),0);
return;
}
if(iLengthBody > (m_iReadedSize-iHEADER_SIZE) )
{
// 바디가 iLengthBody만큼 못읽었으모.
_async_read_some();
return;
}
size_t iStayReadedSize = m_iReadedSize;
try
{
for(;;)
{
if(!m_pPlugin->MOB_OnReadPacket(pBody, iLengthBody))
{
DoDisconnect(__FUNCTION__,0);
return;
}
iStayReadedSize -= (iLengthBody+iHEADER_SIZE);
if(iStayReadedSize<=0)
{
m_iReadedSize=0;
break;
}
jWARN(_T("data뭉쳐서왔다."));
if(iStayReadedSize<= iHEADER_SIZE)
{
memmove(m_pDataBuff_Readed, pBody, iStayReadedSize);
m_iReadedSize=iStayReadedSize;
break;
}
//파싱할 패킷이 남았다.
pBody = pBody+iLengthBody;
memcpy(&iLengthBody,pBody,iHEADER_SIZE);
if(iLengthBody > (int)(iStayReadedSize-iHEADER_SIZE ) ) //아직 바디 데이타가 완성안되었으모.
{
memmove(m_pDataBuff_Readed, pBody, iLengthBody);
m_iReadedSize=iLengthBody;
break;
}
pBody+=iHEADER_SIZE;
}//for(;;)
_async_read_some();
}
catch (...)
{
DoDisconnect("MOB_Connection::handle_read try",0);
}
}
示例13: equivalent
bool equivalent (boost::system::error_code const& code, int ev) const noexcept
{
return *this == code.category() && code.value() == ev;
}
示例14: handle_read
void downloader_instance_simple::handle_read(const boost::system::error_code& ec, std::size_t length)
{
if (!ec)
{
ofstream_.write(buffer_, length);
readed_bytes_ += length;
if (owner()->progress_notify_)
owner()->progress_notify_(readed_bytes_);
{
boost::mutex::scoped_lock lock(owner()->stateGuard_);
while (owner()->command_ != http_downloader_simple::commandNull)
{
switch (owner()->command_)
{
case http_downloader_simple::commandPause:
{
owner()->state_ = http_downloader_simple::statePaused;
owner()->command_ = http_downloader_simple::commandNull;
if (owner()->state_notify_)
owner()->state_notify_(http_downloader::statePause);
while (
owner()->command_ != http_downloader_simple::commandCancel &&
owner()->command_ != http_downloader_simple::commandResume
)
{
lock.unlock();
boost::this_thread::sleep( boost::posix_time::milliseconds(100) );
lock.lock();
}
if (owner()->command_ == http_downloader_simple::commandResume)
{
owner()->state_ = http_downloader_simple::stateDownload;
owner()->command_ = http_downloader_simple::commandNull;
if (owner()->state_notify_)
owner()->state_notify_(http_downloader::stateResume);
}
}
break;
case http_downloader_simple::commandCancel:
{
owner()->command_ = http_downloader_simple::commandNull;
ofstream_.close();
if (owner()->state_notify_)
owner()->state_notify_(http_downloader::stateCancel);
return;
}
break;
case http_downloader_simple::commandResume:
break;
}
}
}
read_stream_.async_read_some(
boost::asio::buffer(buffer_),
boost::bind(&downloader_instance_simple::handle_read,
shared_from_this(), _1, _2));
}
else
{
ofstream_.close();
if ( boost::asio::error::misc_category == ec.category() )
{
if (boost::asio::error::eof == ec.value())
{
if (owner()->state_notify_)
owner()->state_notify_(http_downloader::stateFinish);
}
}
else
{
if (owner()->state_notify_)
owner()->state_notify_(http_downloader::stateError);
}
}
}
示例15: last_error_enum
error::errors last_error_enum(
boost::system::error_code const & ec)
{
if (!ec) {
return success;
} else if (ec == boost::asio::error::would_block) {
return would_block;
} else if (ec == ppbox::demux::error::no_more_sample) {
return stream_end;
} else if (ec == boost::asio::error::operation_aborted) {
return operation_canceled;
} else if (ec == boost::asio::error::connection_aborted) {
return operation_canceled;
} else if (ec.category() == ppbox::error::get_category()) {
return (error::errors)ec.value();
} else if (ec.category() == ppbox::certify::error::get_category()) {
return certify_error;
#ifdef PPBOX_CERTIFY_ERROR_AUTH_ERRORS
} else if (ec.category() == ppbox::certify::error::get_auth_category()) {
return certify_error;
#endif
#ifdef PPBOX_CERTIFY_ERROR_MUTEX_ERRORS
} else if (ec.category() == ppbox::certify::error::get_mutex_category()) {
return certify_error;
#endif
} else if (ec.category() == ppbox::demux::error::get_category()) {
return demux_error;
} else if (ec.category() == framework::system::logic_error::get_category()) {
return ppbox::error::logic_error;
} else if (ec.category() == util::protocol::http_error::get_category()) {
return network_error;
} else if (ec.category() == boost::asio::error::get_system_category()) {
return network_error;
} else if (ec.category() == boost::asio::error::get_netdb_category()) {
return network_error;
} else if (ec.category() == boost::asio::error::get_addrinfo_category()) {
return network_error;
} else if (ec.category() == boost::asio::error::get_misc_category()) {
return network_error;
} else {
return other_error;
}
}