MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / write

Method write

libminifi/src/io/ClientSocket.cpp:502–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500// data stream overrides
501
502int Socket::write(const uint8_t *value, int size) {
503 gsl_Expects(size >= 0);
504
505 int ret = 0, bytes = 0;
506
507 int fd = select_descriptor(1000);
508 if (fd < 0) { return -1; }
509 while (bytes < size) {
510 ret = send(fd, reinterpret_cast<const char*>(value) + bytes, size - bytes, 0);
511 // check for errors
512 if (ret <= 0) {
513 utils::file::FileUtils::close(fd);
514 logger_->log_error("Could not send to %d, error: %s", fd, get_last_socket_error_message());
515 return ret;
516 }
517 bytes += ret;
518 }
519
520 if (ret)
521 logger_->log_trace("Send data size %d over socket %d", size, fd);
522 total_written_ += bytes;
523 return bytes;
524}
525
526int Socket::read(uint8_t *buf, int buflen, bool retrieve_all_bytes) {
527 gsl_Expects(buflen >= 0);

Callers

nothing calls this directly

Calls 4

closeFunction · 0.85
log_errorMethod · 0.80
log_traceMethod · 0.80

Tested by

no test coverage detected