| 130 | } |
| 131 | |
| 132 | bool CBlockingSocket::Accept(IBlockingSocket& sConnect, LPSOCKADDR psa) const |
| 133 | { |
| 134 | ASSERT( psa != NULL ); |
| 135 | ASSERT( m_hSocket!=INVALID_SOCKET ); |
| 136 | ASSERT( sConnect.operator SOCKET() == INVALID_SOCKET ); |
| 137 | |
| 138 | // ATTENTION: dynamic_cast would be better (and then checking against NULL) |
| 139 | // RTTI must be enabled to use dynamic_cast //+# |
| 140 | CBlockingSocket* pConnect = static_cast<CBlockingSocket*>(&sConnect); |
| 141 | |
| 142 | socklen_t nLengthAddr = sizeof(SOCKADDR); |
| 143 | pConnect->m_hSocket = accept(m_hSocket, psa, &nLengthAddr); |
| 144 | |
| 145 | if( pConnect->operator SOCKET()==INVALID_SOCKET ) |
| 146 | { |
| 147 | // no exception if the listen was canceled |
| 148 | if( WSAGetLastError() !=WSAEINTR ) |
| 149 | { |
| 150 | throw CBlockingSocketException(_T("Accept")); |
| 151 | } |
| 152 | return false; |
| 153 | } |
| 154 | return true; |
| 155 | } |
| 156 | |
| 157 | void CBlockingSocket::Close() |
| 158 | { |
no test coverage detected