本文整理汇总了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);
}
示例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));
}
}
示例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();
}
示例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);
}
示例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);
}
}
示例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;
}
示例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()));
}
示例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);
}