* Processes data that can be written for this socket. */
| 301 | * Processes data that can be written for this socket. |
| 302 | */ |
| 303 | size_t Socket::Read(void *buffer, size_t count) |
| 304 | { |
| 305 | int rc; |
| 306 | |
| 307 | #ifndef _WIN32 |
| 308 | rc = read(GetFD(), (char *)buffer, count); |
| 309 | #else /* _WIN32 */ |
| 310 | rc = recv(GetFD(), (char *)buffer, count, 0); |
| 311 | #endif /* _WIN32 */ |
| 312 | |
| 313 | if (rc < 0) { |
| 314 | #ifndef _WIN32 |
| 315 | Log(LogCritical, "Socket") |
| 316 | << "recv() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\""; |
| 317 | |
| 318 | BOOST_THROW_EXCEPTION(socket_error() |
| 319 | << boost::errinfo_api_function("recv") |
| 320 | << boost::errinfo_errno(errno)); |
| 321 | #else /* _WIN32 */ |
| 322 | Log(LogCritical, "Socket") |
| 323 | << "recv() failed with error code " << WSAGetLastError() << ", \"" << Utility::FormatErrorNumber(WSAGetLastError()) << "\""; |
| 324 | |
| 325 | BOOST_THROW_EXCEPTION(socket_error() |
| 326 | << boost::errinfo_api_function("recv") |
| 327 | << errinfo_win32_error(WSAGetLastError())); |
| 328 | #endif /* _WIN32 */ |
| 329 | } |
| 330 | |
| 331 | return rc; |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * Accepts a new client and creates a new client object for it. |
nothing calls this directly
no test coverage detected