MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / Select

Method Select

plugins/dm.gameconnection/clsocket/SimpleSocket.cpp:1129–1188  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Select() ------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1127//
1128//------------------------------------------------------------------------------
1129bool CSimpleSocket::Select(int32 nTimeoutSec, int32 nTimeoutUSec)
1130{
1131 bool bRetVal = false;
1132 struct timeval *pTimeout = NULL;
1133 struct timeval timeout;
1134 int32 nNumDescriptors = -1;
1135 int32 nError = 0;
1136
1137 FD_ZERO(&m_errorFds);
1138 FD_ZERO(&m_readFds);
1139 FD_ZERO(&m_writeFds);
1140 FD_SET(m_socket, &m_errorFds);
1141 FD_SET(m_socket, &m_readFds);
1142 FD_SET(m_socket, &m_writeFds);
1143
1144 //---------------------------------------------------------------------
1145 // If timeout has been specified then set value, otherwise set timeout
1146 // to NULL which will block until a descriptor is ready for read/write
1147 // or an error has occurred.
1148 //---------------------------------------------------------------------
1149 if ((nTimeoutSec > 0) || (nTimeoutUSec > 0))
1150 {
1151 timeout.tv_sec = nTimeoutSec;
1152 timeout.tv_usec = nTimeoutUSec;
1153 pTimeout = &timeout;
1154 }
1155
1156 nNumDescriptors = SELECT(m_socket+1, &m_readFds, &m_writeFds, &m_errorFds, pTimeout);
1157// nNumDescriptors = SELECT(m_socket+1, &m_readFds, NULL, NULL, pTimeout);
1158
1159 //----------------------------------------------------------------------
1160 // Handle timeout
1161 //----------------------------------------------------------------------
1162 if (nNumDescriptors == 0)
1163 {
1164 SetSocketError(CSimpleSocket::SocketTimedout);
1165 }
1166 //----------------------------------------------------------------------
1167 // If a file descriptor (read/write) is set then check the
1168 // socket error (SO_ERROR) to see if there is a pending error.
1169 //----------------------------------------------------------------------
1170 else if ((FD_ISSET(m_socket, &m_readFds)) || (FD_ISSET(m_socket, &m_writeFds)))
1171 {
1172 int32 nLen = sizeof(nError);
1173
1174 if (GETSOCKOPT(m_socket, SOL_SOCKET, SO_ERROR, &nError, &nLen) == 0)
1175 {
1176 errno = nError;
1177
1178 if (nError == 0)
1179 {
1180 bRetVal = true;
1181 }
1182 }
1183
1184 TranslateSocketError();
1185 }
1186

Callers 15

setSelectedAnimMethod · 0.45
onModelLoadedMethod · 0.45
populateWindowMethod · 0.45
populateWindowMethod · 0.45
selectMaterialMethod · 0.45
selectStageByIndexMethod · 0.45

Calls

no outgoing calls

Tested by 1