* Sends data for the socket. */
| 267 | * Sends data for the socket. |
| 268 | */ |
| 269 | size_t Socket::Write(const void *buffer, size_t count) |
| 270 | { |
| 271 | int rc; |
| 272 | |
| 273 | #ifndef _WIN32 |
| 274 | rc = write(GetFD(), (const char *)buffer, count); |
| 275 | #else /* _WIN32 */ |
| 276 | rc = send(GetFD(), (const char *)buffer, count, 0); |
| 277 | #endif /* _WIN32 */ |
| 278 | |
| 279 | if (rc < 0) { |
| 280 | #ifndef _WIN32 |
| 281 | Log(LogCritical, "Socket") |
| 282 | << "send() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\""; |
| 283 | |
| 284 | BOOST_THROW_EXCEPTION(socket_error() |
| 285 | << boost::errinfo_api_function("send") |
| 286 | << boost::errinfo_errno(errno)); |
| 287 | #else /* _WIN32 */ |
| 288 | Log(LogCritical, "Socket") |
| 289 | << "send() failed with error code " << WSAGetLastError() << ", \"" << Utility::FormatErrorNumber(WSAGetLastError()) << "\""; |
| 290 | |
| 291 | BOOST_THROW_EXCEPTION(socket_error() |
| 292 | << boost::errinfo_api_function("send") |
| 293 | << errinfo_win32_error(WSAGetLastError())); |
| 294 | #endif /* _WIN32 */ |
| 295 | } |
| 296 | |
| 297 | return rc; |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Processes data that can be written for this socket. |
nothing calls this directly
no test coverage detected