当前位置: 首页>>代码示例>>C++>>正文


C++ error_code::value方法代码示例

本文整理汇总了C++中boost::system::error_code::value方法的典型用法代码示例。如果您正苦于以下问题:C++ error_code::value方法的具体用法?C++ error_code::value怎么用?C++ error_code::value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::system::error_code的用法示例。


在下文中一共展示了error_code::value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readCompleted

void SerialDevice::readCompleted(const boost::system::error_code& error,
        const size_t bytesTransferred)
{
    if(!error)
    {
        pImpl->result=resultSuccess;
        pImpl->bytesTransferred=bytesTransferred;
        return;
    }

    //In case a asynchronous operation is cancelled due to a timeout,
    //each OS seems to have its way to react.
    #ifdef _WIN32
    if(error.value()==995) return; //Windows spits out error 995
    #elif defined(__APPLE__)
    if(error.value()==45)
    {
        //Bug on OS X, it might be necessary to repeat the setup
        //http://osdir.com/ml/lib.boost.asio.user/2008-08/msg00004.html
        pImpl->port.async_read_some(
                asio::buffer(pImpl->readBuffer,pImpl->readBufferSize),
                boost::bind(&SerialDevice::readCompleted,this,boost::asio::placeholders::error,
                boost::asio::placeholders::bytes_transferred));
        return;
    }
    #else //Linux
    if(error.value()==125) return; //Linux outputs error 125
    #endif

    pImpl->result=resultError;
}
开发者ID:meiser,项目名称:fmp100,代码行数:31,代码来源:SerialStream.cpp

示例2: readMsg

void RemoteClient::readMsg(const boost::system::error_code& err) {
  if(m_marked_for_delete) {
    return;
  } else if(err) {
    switch(err.value()) {
      case ENOENT:
        std::cerr << "QntServer: client socket closed.\n";
        break;
      default:
        std::cerr << "QntServer: got error reading from socket <" << strerror(err.value()) << ">\n";
    }
    m_server->removeClient(this);
    m_marked_for_delete = true;
    m_service.post(boost::bind(&RemoteClient::deleteSelf, this));
    return;
  }
  ServerMsg *msg = ServerMsg::create(m_next_msg_type, this);
  if(msg) {
    msg->read(m_wrapper);
    m_server->pushMessage(msg);
    boost::asio::async_read(m_socket, boost::asio::buffer((char*)&m_next_msg_type, 4),
                            boost::bind(&RemoteClient::readMsg, this, boost::asio::placeholders::error));
  } else {
    std::cerr << "QntServer: received unknown message of type <" << m_next_msg_type << ">\n";
    std::cerr << "QntServer: closing stream due to unknown error.\n";
    m_server->removeClient(this);
    m_marked_for_delete = true;
    m_service.post(boost::bind(&RemoteClient::deleteSelf, this));
  }
}
开发者ID:branan,项目名称:quintses,代码行数:30,代码来源:remoteclient.cpp

示例3: handle_timer_event

/*!
 *
 * @param error
 */
void Timer::handle_timer_event(const boost::system::error_code& error,
      int TimerId) {
   if (verbose) {
      std::cout << "handle_timer_event, Timerid = " << TimerId << std::endl;
   }
   switch (error.value()) {
   case boost::system::errc::success: {
      if (interval_) {
         timer_func_handler_pntr(TimerId);
         _TimerList.pop_front();
         initiate_timer();
      } else {

      }
   }
      break;

   case boost::system::errc::operation_canceled: {
      std::cout << "Timer " << TimerId << " cancelled" << std::endl;
   }
      break;

   default: {
      std::cout << "Assert unexpected case Timer = " << TimerId << " Error = "
            << error.value() << std::endl;
   }
      break;
   }
}
开发者ID:Rosi2143,项目名称:HouseWorkspace,代码行数:33,代码来源:Timer.cpp

示例4: HandleTcpSend

// void TCPSocket::HandleTcpSend(const boost::asio::error& err, size_t bytes_transferred, MyBuffer b)
void TCPClientSocket::HandleTcpSend(const boost::system::error_code& err, size_t bytes_transferred)
{
	if ( m_SendQueue.empty() )
	{
		//TRACE("HandleTcpSend %lu %d\n", GetCurrentThreadId(), m_Socket->GetSocket().native());
		APP_ERROR("TCPClientSocket::HandleTcpSend invalid empty buffer " << make_tuple( err.value(), bytes_transferred, m_SendQueue.size() ));
		assert(false == m_Socket->GetSocket().is_open());
		return;
	}
	m_SendQueue.pop_front();
	if ( err )
	{
		// ·¢ËÍʧ°Ü
		APP_ERROR("TCPClientSocket::HandleTcpSend error " << make_tuple( err.value(), bytes_transferred, m_SendQueue.size() ));
		this->GetListener()->OnSocketReceiveFailed(this, err.value());
	}
	else
	{
		if ( m_SendQueue.empty() )
		{
			return;
		}
		else
		{
			this->DoAsyncSend(m_SendQueue.front());
		}
	}
}
开发者ID:uvbs,项目名称:XDLL,代码行数:29,代码来源:socket.cpp

示例5: onReadSection

void DVBProvider::onReadSection(
	boost::asio::posix::stream_descriptor *io,
	ID pid,
	util::Buffer *buf,
	const boost::system::error_code& error,
	size_t transferred )
{
	bool tryRead=true;
	
	if (error) {
		if (error.value() == boost::system::errc::timed_out) {
			//	Timeout
			timeout( pid );
		}
		else if (error.value() != boost::system::errc::value_too_large) {
			printf( "[DVBProvider] Read section error!!!: err(%s,%d), pid=%04x, transferred=%d, capacity=%d!\n",
				error.message().c_str(), error.value(), pid, transferred, buf->capacity() );
			tryRead=false;
		}
	}
	
	if (transferred) {
		buf->resize( transferred );
		enqueue( pid, buf );
		buf = NULL;
	}

	if (tryRead) {
		readSection( io, pid, buf );
	}
	else {
		freeNetworkBuffer( buf );
	}
}
开发者ID:ezequielgarcia,项目名称:ginga.ar-diet,代码行数:34,代码来源:dvbprovider.cpp

示例6: readCompleted

void TimeoutSerial::readCompleted(const boost::system::error_code& error,
        const size_t bytesTransferred)
{
    if(!error)
    {
        result=resultSuccess;
        this->bytesTransferred=bytesTransferred;
        return;
    }

    //In case a asynchronous operation is cancelled due to a timeout,
    //each OS seems to have its way to react.
    #ifdef _WIN32
    if(error.value()==995) return; //Windows spits out error 995
    #elif defined(__APPLE__)
    if(error.value()==45)
    {
        //Bug on OS X, it might be necessary to repeat the setup
        //http://osdir.com/ml/lib.boost.asio.user/2008-08/msg00004.html
        performReadSetup(setupParameters);
        return;
    }
    #else //Linux
    if(error.value()==125) return; //Linux outputs error 125
    #endif

    result=resultError;
}
开发者ID:DK999,项目名称:SIRKA_Configurator,代码行数:28,代码来源:TimeoutSerial.cpp

示例7: read_handle

void c_udp_wrapper_asio::read_handle(const boost::system::error_code& error, size_t bytes_transferred) {
//	std::cout << "udp read handle" << std::endl;
//	std::cout << "readed " << bytes_transferred << " bytes" << std::endl;
	if (error && (error.value() != 10061)) // http://stackoverflow.com/a/16763404
		std::cout << error.message() << " value " << error.value() << std::endl;
//	assert(m_bytes_readed == 0);
	m_bytes_readed = bytes_transferred;
	m_socket.async_receive_from(boost::asio::buffer(m_buffer), m_sender_endpoint,
			boost::bind(&c_udp_wrapper_asio::read_handle, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
开发者ID:robertoleksy,项目名称:galaxy42,代码行数:10,代码来源:c_udp_wrapper.cpp

示例8: report

inline void length_framed_connection::report(boost::system::error_code ec) {
  switch (ec.value()) {
    case io::error::eof:
      report(std::errc::not_connected);
      break;
    default:
      report(static_cast<std::errc>(ec.value()));
      break;
  }
}
开发者ID:reinfer,项目名称:riakpp,代码行数:10,代码来源:length_framed_connection.cpp

示例9: handle_send

/// dummy function, called after send
void CBoostTapNetAdapt::handle_send (boost::shared_ptr<CNetworkFrame> frame, const boost::system::error_code& error, std::size_t bytes_transferred)
{
	if (error.value() != 0) {
		DBG_ERROR(FMT("Error sending data (%1%): %2%") % error.value() % error.message());

	} else if (bytes_transferred != frame->size) {
		DBG_ERROR(FMT("bytes transferred (%1%) != buffer size (%2%)!") % bytes_transferred % frame->size);

	}
}
开发者ID:denis-martin,项目名称:nena,代码行数:11,代码来源:netAdaptBoostTap.cpp

示例10: OnSendComplete

void OnSendComplete(const boost::system::error_code &err, CMsgBuffer::Ptr msg)
{
	std::cout << "ErrorCode" << err.value() << std::endl;
	if (err.value() == boost::asio::error::not_connected)
	{
		cli.Reset();
		return;
	}
	std::cout << "OnSendComplete" << std::endl;
	std::cout << "OnSendComplete times \"" << times++ << "\"" <<std::endl;
}
开发者ID:asherzhou,项目名称:client,代码行数:11,代码来源:demo.cpp

示例11: HandleReadSome

void TtyStream::HandleReadSome(int reference, const boost::system::error_code& error, size_t bytes_transferred)
{
	lua_State* L = LuaNode::GetLuaVM();
	lua_rawgeti(L, LUA_REGISTRYINDEX, reference);
	luaL_unref(L, LUA_REGISTRYINDEX, reference);

	m_pending_reads--;
	if(!error) {
		LogDebug("TtyStream::HandleReadSome (%p) (id:%u) - Bytes Transferred (%lu)\n", this, m_fd, (unsigned long)bytes_transferred);
		lua_getfield(L, 1, "read_callback");
		if(lua_type(L, 2) == LUA_TFUNCTION) {
			lua_pushvalue(L, 1);
			const char* data = m_inputArray.c_array();
			lua_pushlstring(L, data, bytes_transferred);
			LuaNode::GetLuaVM().call(2, LUA_MULTRET);
		}
		else {
			// do nothing?
			if(lua_type(L, 1) == LUA_TUSERDATA) {
				userdataType* ud = static_cast<userdataType*>(lua_touserdata(L, 1));
				LogWarning("TtyStream::HandleReadSome (%p) (id:%u) - No read_callback set on %s (address: %p, possible obj: %p)", this, m_fd, luaL_typename(L, 1), ud, ud->pT);
			}
			else {
				LogWarning("TtyStream::HandleReadSome (%p) (id:%u) - No read_callback set on %s", this, m_fd, luaL_typename(L, 1));
			}
		}
	}
	else {
		lua_getfield(L, 1, "read_callback");
		if(lua_type(L, 2) == LUA_TFUNCTION) {
			lua_pushvalue(L, 1);
			LuaNode::BoostErrorCodeToLua(L, error);	// -> nil, error code, error message

			if(error.value() != boost::asio::error::eof && error.value() != boost::asio::error::operation_aborted) {
				LogError("TtyStream::HandleReadSome with error (%p) (id:%u) - %s", this, m_fd, error.message().c_str());
			}

			LuaNode::GetLuaVM().call(4, LUA_MULTRET);
		}
		else {
			LogError("TtyStream::HandleReadSome with error (%p) (id:%u) - %s", this, m_fd, error.message().c_str());
			if(lua_type(L, 1) == LUA_TUSERDATA) {
				userdataType* ud = static_cast<userdataType*>(lua_touserdata(L, 1));
				LogWarning("TtyStream::HandleReadSome (%p) (id:%u) - No read_callback set on %s (address: %p, possible obj: %p)", this, m_fd, luaL_typename(L, 1), ud, ud->pT);
			}
			else {
				LogWarning("TtyStream::HandleReadSome (%p) (id:%u) - No read_callback set on %s", this, m_fd, luaL_typename(L, 1));
			}
		}
	}
	lua_settop(L, 0);
}
开发者ID:CoolisTheName007,项目名称:LuaNode,代码行数:52,代码来源:tty_stream.cpp

示例12: recvSerialPortErrorCB

void TransPanel::recvSerialPortErrorCB(boost::system::error_code ec)
{
	if(ec.value() != 995)
	{
		LOG( "%d - %s" , ec.value() ,   ec.message().c_str());

		QString com_error;
		com_error.sprintf("串口读取错误:%s" ,ec.message().c_str() );
		SERROR(com_error);
	}


}
开发者ID:csyangbinbin,项目名称:TransPanel,代码行数:13,代码来源:transpanel.cpp

示例13: CheckErrorCode

bool CheckErrorCode(boost::system::error_code& err)
{
	// connection reset can happen when host did not start up
	// before the client wants to connect
	if (!err || err.value() == connection_reset || 
		err.value() == resource_unavailable_try_again) { // this should only ever happen with async sockets, but testing indicates it happens anyway...
		return false;
	} else {
		LOG_L(L_WARNING, "Network error %i: %s", err.value(),
				err.message().c_str());
		return true;
	}
}
开发者ID:AMDmi3,项目名称:spring,代码行数:13,代码来源:Socket.cpp

示例14: data_recv_handler

void basic_socket_impl::data_recv_handler(const boost::system::error_code& ec, size_t bytes_transferred, bool ischeck)
{
	if (!isworking()) return;
	if (ec.value() == 0) {
		recv_helper_.reading_buffer_.use_buffer(bytes_transferred);
		int ret = on_data_recv(bytes_transferred);
		if (ret == 0) {
			if (recv_helper_.reading_buffer_.buffer_left() < 128) {
				recv_helper_.reading_buffer_.remove_used();
			}

			//如果不是超时回调,则重置接收状态
			if (!ischeck) {
				recv_helper_.is_recving_ = false;
			}

			//如果缓冲有空闲,并且没有在接收状态
			if (recv_helper_.reading_buffer_.buffer_left() > 0 && !recv_helper_.is_recving_) {
				recv_helper_.is_recving_ = true;
				s.async_receive(
					boost::asio::buffer(recv_helper_.reading_buffer_.buffer(), recv_helper_.reading_buffer_.buffer_left()),
					boost::bind(&basic_socket_impl::data_recv_handler,
						this->shared_from_this(),
						boost::asio::placeholders::error,
						boost::asio::placeholders::bytes_transferred,
						false));
			}
			else if (recv_helper_.reading_buffer_.buffer_left() == 0) {
				if (option("close_on_rdbuffer_full") == "1") {
					last_socket_error_ = 10055;
					close(true);
				}
				else {
					recv_helper_.is_recving_ = false;
					//缓冲区满了,10ms后再读数据,让目前的数据有时间处理
					check_data_recv_.expires_from_now(boost::posix_time::millisec(1));
					check_data_recv_.async_wait(
						boost::bind(&basic_socket_impl::on_recv_check,
							this->shared_from_this(),
							boost::asio::placeholders::error));
				}
			}
		}
	}
	else {
		if (work_state != work_state_closed) {
			last_socket_error_ = ec.value();
			close(true);
		}
	}
}
开发者ID:ghosthjt,项目名称:server_client_common,代码行数:51,代码来源:net_socket_basic.cpp

示例15: OnWrite

void CNetwork::OnWrite(const boost::system::error_code &error_code)
{
	boost::lock_guard<boost::mutex> lock_guard(m_CmdWriteBufferQueueMutex);
#ifdef _DEBUG
	logprintf("<<<< %s", m_CmdWriteBufferQueue.front().c_str());
#endif
	m_CmdWriteBufferQueue.pop();
	if (error_code.value() != 0)
	{
		CCallbackHandler::Get()->ForwardError(
			EErrorType::CONNECTION_ERROR, error_code.value(),
			fmt::format("error while writing: {}", error_code.message()));
	}
}
开发者ID:maddinat0r,项目名称:samp-tsconnector,代码行数:14,代码来源:CNetwork.cpp


注:本文中的boost::system::error_code::value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。