コード例 #1
0
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
0
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
0
ファイル: SocketRegistry.hpp プロジェクト: SunguckLee/MariaDB
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;
}
コード例 #4
0
ファイル: SocketRegistry.hpp プロジェクト: SunguckLee/MariaDB
inline
bool 
SocketRegistry<T>::performSend(const char * buf, Uint32 len, const char * remotehost)
{
  SocketClient * socketClient;
  for(Uint32 i=0; i < m_nSocketClients; i++) {
    socketClient = m_socketClients[i];
    if(strcmp(socketClient->gethostname(), remotehost)==0) {
      if(socketClient->isConnected()) {
	if(socketClient->writeSocket(buf, len)>0)
	  return true;
	else
	  return false;
      }
    }
  }
  return false;
}