| 200 | } |
| 201 | |
| 202 | virtual unsigned int ReadRealiableData( void* out_data, unsigned int buffer_size ) override |
| 203 | { |
| 204 | if( disconnected_ ) return 0u; |
| 205 | |
| 206 | if( IsSocketReady( tcp_socket_ ) ) |
| 207 | { |
| 208 | #ifdef _WIN32 |
| 209 | int result= ::recv( tcp_socket_, (char*) out_data, buffer_size, 0 ); |
| 210 | if( result == SOCKET_ERROR ) |
| 211 | Log::Warning( FUNC_NAME, " error: ", ::WSAGetLastError() ); |
| 212 | #else |
| 213 | int result= ::recv( tcp_socket_, (char*) out_data, buffer_size, 0 ); |
| 214 | if( result == -1 ) |
| 215 | Log::Warning( FUNC_NAME, " error: ", errno ); |
| 216 | #endif |
| 217 | // If socket is ready, but recv return zero, this means, that other side closes connection. |
| 218 | if( result == 0 ) |
| 219 | Disconnect(); |
| 220 | |
| 221 | return std::max( 0, result ); |
| 222 | } |
| 223 | return 0u; |
| 224 | } |
| 225 | |
| 226 | virtual unsigned int ReadUnrealiableData( void* out_data, unsigned int buffer_size ) override |
| 227 | { |
nothing calls this directly
no test coverage detected