Example #1
0
std::unique_ptr<Socket> Acceptor::accept() {
  rdma_cm_id* new_cm_id;
  if (rdma_get_request(m_cm_id, &new_cm_id)) {
    throw exception::acceptor::generic_error(
        "Error on rdma_get_request: " + std::string(strerror(errno)));
  }

  rdma_conn_param conn_param;
  memset(&conn_param, 0, sizeof(rdma_conn_param));
  conn_param.rnr_retry_count = m_rnr_retry_count;
  if (rdma_accept(new_cm_id, &conn_param)) {
    rdma_destroy_ep(new_cm_id);
    throw exception::acceptor::generic_error(
        "Error on rdma_accept: " + std::string(strerror(errno)));
  }

  ibv_qp_attr attr;
  memset(&attr, 0, sizeof(ibv_qp_attr));
  attr.min_rnr_timer = m_min_rtr_timer;
  int flags = IBV_QP_MIN_RNR_TIMER;
  if (ibv_modify_qp(new_cm_id->qp, &attr, flags)) {
    rdma_destroy_ep(new_cm_id);
    throw exception::acceptor::generic_error(
        "Error on ibv_modify_qp: " + std::string(strerror(errno)));
  }

  std::unique_ptr<Socket> socket_ptr(new Socket(new_cm_id, m_credits));
  return socket_ptr;
}
void SocketBackEnd::StartAsyncAccept()
{
//	tcp_connection::pointer new_connection =
//		tcp_connection::create(m_pAcceptor->io_service());

	_pSocket= socket_ptr( new tcp::socket(_io_service));

	_pAcceptor->async_accept(*_pSocket, bind(&SocketBackEnd::HandleAsyncAccept, this, boost::asio::placeholders::error));   
}
Example #3
0
    /** Start a new connection on the given endpoint. This method can be called
      * multiple times to publish the same data on multiple endpoints.
      *
      * \param[in] addr address to bind server to.
      * \throws ib_error on error.
      */
    virtual void startup(const std::string &addr = "tcp://127.0.0.1:6000")
    { 
      if (!network_entity::_s) {
        network_entity::_s = socket_ptr(new zmq::socket_t(*network_entity::_ctx, ZMQ_PUB));
        network_entity::apply_socket_options();
      }

      IB_CATCH_ZMQ_RETHROW(network_entity::_s->bind(addr.c_str()));
    }
XMLClient::XMLClient(boost::asio::io_service* ioservice) :
_io_service(ioservice) {
    _bConnected = false;
    TagReset();
    _nMSServerConnectRetry = 2000;
    _bWaitConnect = false;
    _socket = socket_ptr(new boost::asio::ip::tcp::socket(*ioservice));
    _timer = deadline_timer_ptr(new boost::asio::deadline_timer(*ioservice,
            boost::posix_time::milliseconds(2000)));
    //_timer->async_wait(b1oost::bind(&XMLClient::wait_callback, this, _1, boost::ref(*_socket)));
}
Example #5
0
    /** Start a new connection to the given endpoint. If called multiple times, the client
      * will connect to more endpoints. 
      *
      * \param [in] addr endpoint address to connect to
      * \throws ib_error on error
      */      
    virtual void startup(const std::string &addr = "tcp://127.0.0.1:6000")
    {
      if (!network_entity::_s) {
        network_entity::_s = socket_ptr(new zmq::socket_t(*network_entity::_ctx, ZMQ_SUB));
      
        network_entity::apply_socket_options();
        IB_CATCH_ZMQ_RETHROW(network_entity::_s->setsockopt(ZMQ_SUBSCRIBE, 0, 0));

        size_t recvhwm_size = sizeof (_recv_skip);
        IB_CATCH_ZMQ_RETHROW(network_entity::_s->getsockopt(ZMQ_RCVHWM, &_recv_skip, &recvhwm_size));

      }

      IB_CATCH_ZMQ_RETHROW(network_entity::_s->connect(addr.c_str()));
    }
void AcceptSession::AsyncListen()
{
  SocketPtr socket_ptr(new SocketData(m_io_service));
  m_acceptor.async_accept(socket_ptr->GetSocket(), 
                          boost::bind(&AcceptSession::OnAccept, this, socket_ptr, boost::asio::placeholders::error));
}
Example #7
0
	void send_and_record_server_message(const std::string& message,	const socket_ptr exclude=socket_ptr())
	{
		send_and_record_server_message(message.c_str(), exclude);
	}
Example #8
0
	void send_server_message(const std::string& message, socket_ptr sock=socket_ptr(), simple_wml::document* doc=nullptr) const
	{
		send_server_message(message.c_str(), sock, doc);
	}
Example #9
0
	void send_server_message_to_all(const std::string& message, socket_ptr exclude=socket_ptr()) const
	{
		send_server_message_to_all(message.c_str(), exclude);
	}
Example #10
0
	 */
	bool process_turn(simple_wml::document& data, const socket_ptr user);

	/** Handles incoming [whiteboard] data. */
	void process_whiteboard(simple_wml::document& data, const socket_ptr user);
	/** Handles incoming [change_turns_wml] data. */
	void process_change_turns_wml(simple_wml::document& data, const socket_ptr user);

	/**
	 * Set the description to the number of available slots.
	 *
	 * @returns                   True iff the number of slots has changed.
	 */
	bool describe_slots();

	void send_server_message_to_all(const char* message, socket_ptr exclude=socket_ptr()) const;
	void send_server_message_to_all(const std::string& message, socket_ptr exclude=socket_ptr()) const
	{
		send_server_message_to_all(message.c_str(), exclude);
	}

	void send_server_message(const char* message, socket_ptr sock=socket_ptr(), simple_wml::document* doc=nullptr) const;
	void send_server_message(const std::string& message, socket_ptr sock=socket_ptr(), simple_wml::document* doc=nullptr) const
	{
		send_server_message(message.c_str(), sock, doc);
	}

	/** Send data to all players in this game except 'exclude'. */
	void send_and_record_server_message(const char* message, const socket_ptr exclude=socket_ptr());
	void send_and_record_server_message(const std::string& message,	const socket_ptr exclude=socket_ptr())
	{