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


C++ IPV4SocketAddress::Port方法代码示例

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


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

示例1: AddExpectedData

void MockUDPSocket::AddExpectedData(IOQueue *ioqueue,
                                    const IPV4SocketAddress &dest) {
    unsigned int size;
    uint8_t *data = IOQueueToBuffer(ioqueue, &size);
    expected_call call = {data, size, dest.Host(), dest.Port(), true};
    m_expected_calls.push(call);
}
开发者ID:RenZ0,项目名称:ola,代码行数:7,代码来源:MockUDPSocket.cpp

示例2: Disconnect

void AdvancedTCPConnector::Disconnect(const IPV4SocketAddress &endpoint,
                                      bool pause) {
  IPPortPair key(endpoint.Host(), endpoint.Port());
  ConnectionMap::iterator iter = m_connections.find(key);
  if (iter == m_connections.end())
    return;

  if (iter->second->state != CONNECTED)
    return;

  iter->second->failed_attempts = 0;

  if (pause) {
    iter->second->state = PAUSED;
  } else {
    // schedule a retry as if this endpoint failed once
    iter->second->state = DISCONNECTED;
    iter->second->retry_timeout = m_ss->RegisterSingleTimeout(
        iter->second->policy->BackOffTime(1),
        ola::NewSingleCallback(
          this,
          &AdvancedTCPConnector::RetryTimeout,
          iter->first));
  }
}
开发者ID:DanielAeolusLaude,项目名称:ola,代码行数:25,代码来源:AdvancedTCPConnector.cpp

示例3: InjectData

/**
 * Inject the data in an IOQueue into the socket. This acts as if the data was
 * received on the UDP socket.
 * @param ioqueue the data to inject
 * @param source the socket address where this fake data came from
 */
void MockUDPSocket::InjectData(IOQueue *ioqueue,
                               const IPV4SocketAddress &source) {
    unsigned int data_size;
    // This incurs a copy, but this is just testing code so it doesn't matter.
    uint8_t *data = IOQueueToBuffer(ioqueue, &data_size);
    expected_call call = {data, data_size, source.Host(), source.Port(), true};
    m_received_data.push(call);
    PerformRead();
}
开发者ID:RenZ0,项目名称:ola,代码行数:15,代码来源:MockUDPSocket.cpp

示例4: RemoveEndpoint

void AdvancedTCPConnector::RemoveEndpoint(const IPV4SocketAddress &endpoint) {
  IPPortPair key(endpoint.Host(), endpoint.Port());
  ConnectionMap::iterator iter = m_connections.find(key);
  if (iter == m_connections.end())
    return;

  AbortConnection(iter->second);
  delete iter->second;
  m_connections.erase(iter);
}
开发者ID:DanielAeolusLaude,项目名称:ola,代码行数:10,代码来源:AdvancedTCPConnector.cpp

示例5: Resume

void AdvancedTCPConnector::Resume(const IPV4SocketAddress &endpoint) {
  IPPortPair key(endpoint.Host(), endpoint.Port());
  ConnectionMap::iterator iter = m_connections.find(key);
  if (iter == m_connections.end())
    return;

  if (iter->second->state == PAUSED) {
    iter->second->state = DISCONNECTED;
    AttemptConnection(iter->first, iter->second);
  }
}
开发者ID:DanielAeolusLaude,项目名称:ola,代码行数:11,代码来源:AdvancedTCPConnector.cpp

示例6: GetEndpointState

bool AdvancedTCPConnector::GetEndpointState(
    const IPV4SocketAddress &endpoint,
    ConnectionState *connected,
    unsigned int *failed_attempts) const {
  IPPortPair key(endpoint.Host(), endpoint.Port());
  ConnectionMap::const_iterator iter = m_connections.find(key);
  if (iter == m_connections.end())
    return false;

  *connected = iter->second->state;
  *failed_attempts = iter->second->failed_attempts;
  return true;
}
开发者ID:DanielAeolusLaude,项目名称:ola,代码行数:13,代码来源:AdvancedTCPConnector.cpp

示例7: CheckIfMaster

 bool CheckIfMaster() {
   vector<Master>::iterator iter = m_masters.begin();
   uint8_t priority = 0;
   Master *preferred_master = NULL;
   for (; iter != m_masters.end(); ++iter) {
     if (iter->priority > priority &&
         iter->address.Host() != IPV4Address::WildCard()) {
       preferred_master = &(*iter);
       priority = iter->priority;
     }
   }
   return (preferred_master &&
           preferred_master->address.Port() == m_listen_address.Port() &&
           STLContains(m_local_ips, preferred_master->address.Host()));
 }
开发者ID:nomis52,项目名称:glowing-wookie,代码行数:15,代码来源:master.cpp

示例8: AddEndpoint

/**
 * Add a remote host. This will trigger the connection process to start.
 * If the ip:port already exists this won't do anything.
 * When the connection is successfull the on_connect callback will be run, and
 * ownership of the TCPSocket object is transferred.
 * @param endpoint the IPV4SocketAddress to connect to.
 * @param backoff_policy the BackOffPolicy to use for this connection.
 * @param paused true if we don't want to immediately connect to this peer.
 */
void AdvancedTCPConnector::AddEndpoint(const IPV4SocketAddress &endpoint,
                                       BackOffPolicy *backoff_policy,
                                       bool paused) {
  IPPortPair key(endpoint.Host(), endpoint.Port());
  ConnectionMap::iterator iter = m_connections.find(key);
  if (iter != m_connections.end())
    return;

  // new ip:port
  ConnectionInfo *state = new ConnectionInfo;
  state->state = paused ? PAUSED : DISCONNECTED;
  state->failed_attempts = 0;
  state->retry_timeout = ola::thread::INVALID_TIMEOUT;
  state->connection_id = 0;
  state->policy = backoff_policy;

  m_connections[key] = state;

  if (!paused)
    AttemptConnection(key, state);
}
开发者ID:Jazeido,项目名称:ola,代码行数:30,代码来源:AdvancedTCPConnector.cpp


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