本文整理汇总了C++中SocketClient::gethostname方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketClient::gethostname方法的具体用法?C++ SocketClient::gethostname怎么用?C++ SocketClient::gethostname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketClient
的用法示例。
在下文中一共展示了SocketClient::gethostname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: select
inline
int
SocketRegistry<T>::syncPerformReceive(char * host,
T & t,
Uint32 timeOutMillis) {
char buf[255] ; //temp. just for testing. must fix better
struct timeval timeout;
timeout.tv_sec = timeOutMillis / 1000;
timeout.tv_usec = (timeOutMillis % 1000) * 1000;
int reply;
SocketClient * sc;
for(Uint32 i=0; i < m_nSocketClients; i++) {
sc = m_socketClients[i];
if(strcmp(sc->gethostname(), remotehost)==0) {
if(sc->isConnected()) {
FD_ZERO(&tcpReadset);
reply = select(sc->getSocket(), &tcpReadset, 0, 0, &timeout);
if(reply > 0) {
return t->runSession(sc->getSocket(), t);
}
}
}
}
return 0;
}
示例2:
bool
SocketRegistry<T>::reconnect(const char * host) {
for(Uint32 i=0; i < m_nSocketClients; i++) {
SocketClient * socketClient = m_socketClients[i];
if(strcmp(socketClient->gethostname(), host)==0) {
if(!socketClient->isConnected()) {
if(socketClient->openSocket() > 0)
return true;
else return false;
}
}
}
return false;
}
示例3:
inline
bool
SocketRegistry<T>::removeSocketClient(const char * host){
for(Uint32 i=0; i < m_nSocketClients; i++) {
SocketClient * socketClient = m_socketClients[i];
if(strcmp(socketClient->gethostname(), host)==0) {
if(!socketClient->isConnected()) {
if(socketClient->closeSocket() > 0) {
delete socketClient;
return true;
}
else return false;
}
}
}
return false;
}