MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Write

Method Write

lib/base/socket.cpp:269–298  ·  view source on GitHub ↗

* Sends data for the socket. */

Source from the content-addressed store, hash-verified

267 * Sends data for the socket.
268 */
269size_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.

Callers

nothing calls this directly

Calls 2

LogClass · 0.85
socket_errorClass · 0.85

Tested by

no test coverage detected