| 271 | } |
| 272 | |
| 273 | bool CScriptSocket::IsActive() const |
| 274 | { |
| 275 | if (m_socket == -1) |
| 276 | return false; |
| 277 | |
| 278 | int error_code = 0; |
| 279 | int error_code_size = sizeof(error_code); |
| 280 | int r = getsockopt(m_socket, SOL_SOCKET, SO_ERROR, (char*)&error_code, &error_code_size); |
| 281 | if (r < 0 || error_code != 0) |
| 282 | { |
| 283 | // If an error occurred just close the socket |
| 284 | const_cast<CScriptSocket*>(this)->Close(); |
| 285 | return false; |
| 286 | } |
| 287 | |
| 288 | return true; |
| 289 | } |
| 290 | |
| 291 | static CScriptSocket* CScriptSocket_Factory() |
| 292 | { |