MCPcopy Create free account
hub / github.com/cinder/Cinder / overflow

Method overflow

include/asio/basic_socket_streambuf.hpp:468–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466 }
467
468 int_type overflow(int_type c)
469 {
470#if defined(ASIO_WINDOWS_RUNTIME)
471 ec_ = asio::error::operation_not_supported;
472 return traits_type::eof();
473#else // defined(ASIO_WINDOWS_RUNTIME)
474 char_type ch = traits_type::to_char_type(c);
475
476 // Determine what needs to be sent.
477 const_buffer output_buffer;
478 if (put_buffer_.empty())
479 {
480 if (traits_type::eq_int_type(c, traits_type::eof()))
481 return traits_type::not_eof(c); // Nothing to do.
482 output_buffer = asio::buffer(&ch, sizeof(char_type));
483 }
484 else
485 {
486 output_buffer = asio::buffer(pbase(),
487 (pptr() - pbase()) * sizeof(char_type));
488 }
489
490 while (output_buffer.size() > 0)
491 {
492 // Check if we are past the expiry time.
493 if (traits_helper::less_than(expiry_time_, traits_helper::now()))
494 {
495 ec_ = asio::error::timed_out;
496 return traits_type::eof();
497 }
498
499 // Try to complete the operation without blocking.
500 if (!socket().native_non_blocking())
501 socket().native_non_blocking(true, ec_);
502 detail::buffer_sequence_adapter<
503 const_buffer, const_buffer> bufs(output_buffer);
504 detail::signed_size_type bytes = detail::socket_ops::send(
505 socket().native_handle(), bufs.buffers(), bufs.count(), 0, ec_);
506
507 // Check if operation succeeded.
508 if (bytes > 0)
509 {
510 output_buffer += static_cast<std::size_t>(bytes);
511 continue;
512 }
513
514 // Operation failed.
515 if (ec_ != asio::error::would_block
516 && ec_ != asio::error::try_again)
517 return traits_type::eof();
518
519 // Wait for socket to become ready.
520 if (detail::socket_ops::poll_write(
521 socket().native_handle(), 0, timeout(), ec_) < 0)
522 return traits_type::eof();
523 }
524
525 if (!put_buffer_.empty())

Callers

nothing calls this directly

Calls 8

bufferFunction · 0.85
nowClass · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
native_non_blockingMethod · 0.45
native_handleMethod · 0.45
buffersMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected