| 482 | } |
| 483 | |
| 484 | int_type overflow(int_type c) |
| 485 | { |
| 486 | #if defined(ASIO_WINDOWS_RUNTIME) |
| 487 | ec_ = asio::error::operation_not_supported; |
| 488 | return traits_type::eof(); |
| 489 | #else // defined(ASIO_WINDOWS_RUNTIME) |
| 490 | char_type ch = traits_type::to_char_type(c); |
| 491 | |
| 492 | // Determine what needs to be sent. |
| 493 | const_buffer output_buffer; |
| 494 | if (put_buffer_.empty()) |
| 495 | { |
| 496 | if (traits_type::eq_int_type(c, traits_type::eof())) |
| 497 | return traits_type::not_eof(c); // Nothing to do. |
| 498 | output_buffer = asio::buffer(&ch, sizeof(char_type)); |
| 499 | } |
| 500 | else |
| 501 | { |
| 502 | output_buffer = asio::buffer(pbase(), |
| 503 | (pptr() - pbase()) * sizeof(char_type)); |
| 504 | } |
| 505 | |
| 506 | while (output_buffer.size() > 0) |
| 507 | { |
| 508 | // Check if we are past the expiry time. |
| 509 | if (traits_helper::less_than(expiry_time_, traits_helper::now())) |
| 510 | { |
| 511 | ec_ = asio::error::timed_out; |
| 512 | return traits_type::eof(); |
| 513 | } |
| 514 | |
| 515 | // Try to complete the operation without blocking. |
| 516 | if (!socket().native_non_blocking()) |
| 517 | socket().native_non_blocking(true, ec_); |
| 518 | detail::buffer_sequence_adapter< |
| 519 | const_buffer, const_buffer> bufs(output_buffer); |
| 520 | detail::signed_size_type bytes = detail::socket_ops::send( |
| 521 | socket().native_handle(), bufs.buffers(), bufs.count(), 0, ec_); |
| 522 | |
| 523 | // Check if operation succeeded. |
| 524 | if (bytes > 0) |
| 525 | { |
| 526 | output_buffer += static_cast<std::size_t>(bytes); |
| 527 | continue; |
| 528 | } |
| 529 | |
| 530 | // Operation failed. |
| 531 | if (ec_ != asio::error::would_block |
| 532 | && ec_ != asio::error::try_again) |
| 533 | return traits_type::eof(); |
| 534 | |
| 535 | // Wait for socket to become ready. |
| 536 | if (detail::socket_ops::poll_write( |
| 537 | socket().native_handle(), 0, timeout(), ec_) < 0) |
| 538 | return traits_type::eof(); |
| 539 | } |
| 540 | |
| 541 | if (!put_buffer_.empty()) |
no test coverage detected