bool CTReader::read() { ControllerInf *con = m_decoder.getController(); static bool start_sim = false; static double timewidth = 0.0; struct timeval start, eoa; timeval now; static double server_startTime = 0.0; if (start_sim) { //now = clock(); gettimeofday(&now, NULL); double tmp_time = (double)(now.tv_sec - eoa.tv_sec) + (double)(now.tv_usec - eoa.tv_usec) * 0.001 * 0.001; if (tmp_time >= timewidth) { ActionEvent aevt; double nowtime = (double)(now.tv_sec - start.tv_sec) + (double)(now.tv_usec - start.tv_usec) * 0.001 * 0.001; nowtime += server_startTime; aevt.setTime(nowtime); timewidth = con->onAction(aevt); gettimeofday(&eoa, NULL); Controller *conn = (Controller*)con; //conn->updateObjs(); } } SOCKET s = m_sock; fd_set rfds; struct timeval tv; FD_ZERO(&rfds); FD_SET(s, &rfds); ControllerImpl* coni = (ControllerImpl*)con; std::map<std::string, SOCKET> ssocks = coni->getSrvSocks(); std::map<std::string, SOCKET>::iterator it = ssocks.begin(); while (it != ssocks.end()) { FD_SET((*it).second, &rfds); it++; } tv.tv_sec = 0; //tv.tv_usec = 100000; tv.tv_usec = 1000; int ret = select(FD_SETSIZE, &rfds, NULL, NULL, &tv); if (ret == -1) { perror("select"); return false; } else if (ret == 0) { return true; } else if (ret > 0) { if (FD_ISSET(s, &rfds)) { int rbytes; if (m_buf->datasize() == 0) { rbytes = m_buf->read(s, 4); #if 1 // sekikawa(FIX20100826) if (rbytes < 0) { if (errno == ECONNRESET) { LOG_SYS(("connection closed by service provider [%s:%d]", __FILE__, __LINE__)); } else { LOG_SYS(("socket error (errno=%d) [%s:%d]", errno, __FILE__, __LINE__)); } throw ConnectionClosedException(); } #endif if (rbytes > 0) { char *data = m_buf->data(); char *p = data; unsigned short token = BINARY_GET_DATA_S_INCR(p, unsigned short); if (token == COMM_DATA_PACKET_START_TOKEN) { unsigned short size = BINARY_GET_DATA_S_INCR(p, unsigned short); #if 1 // sekikawa(FIX20100826) int rbytes2 = m_buf->read(s, size-4); if (rbytes2 < 0) { if (errno == ECONNRESET) { LOG_SYS(("connection closed by service provider [%s:%d]", __FILE__, __LINE__)); } else { LOG_SYS(("socket error (errno=%d) [%s:%d]", errno, __FILE__, __LINE__)); } throw ConnectionClosedException(); } rbytes += rbytes2; /* #else // orig rbytes += m_buf->read(s, size-4); } */ #endif } else if (token == START_SIM) {