| 277 | } |
| 278 | |
| 279 | size_t socket::write_some(fl::span<const u8> buffer, error_code &ec) { |
| 280 | ec = error_code(); |
| 281 | if (mFd == -1) { |
| 282 | ec = error_code(errc::operation_aborted, "socket not open"); |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | ssize_t result = plat_send(mFd, (const char *)buffer.data(), |
| 287 | buffer.size(), MSG_NOSIGNAL); |
| 288 | |
| 289 | if (result < 0) { |
| 290 | if (is_would_block()) { |
| 291 | ec = error_code(errc::would_block); |
| 292 | return 0; |
| 293 | } |
| 294 | #ifdef FL_IS_WIN |
| 295 | ec = error_code(errc::unknown, "send failed"); |
| 296 | #else |
| 297 | ec = error_code::from_errno(errno); |
| 298 | #endif |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | return static_cast<size_t>(result); |
| 303 | } |
| 304 | |
| 305 | void socket::async_read_some(fl::span<u8> buffer, io_handler handler) { |
| 306 | error_code ec; |