21 #include "kinetic/reader_writer.h"
26 #include "glog/logging.h"
30 ReaderWriter::ReaderWriter(
int fd) : fd_(fd) {}
32 bool ReaderWriter::Read(
void *buf,
size_t n,
int* err) {
33 size_t bytes_read = 0;
34 while (bytes_read < n) {
35 int status = read(fd_, reinterpret_cast<char *>(buf) + bytes_read, n - bytes_read);
36 if (status == -1 && errno == EINTR) {
41 PLOG(WARNING) <<
"Failed to read from socket";
45 LOG(WARNING) <<
"Failed to read from socket";
54 bool ReaderWriter::Write(
const void *buf,
size_t n) {
55 size_t bytes_written = 0;
56 while (bytes_written < n) {
57 int status = write(fd_, reinterpret_cast<const char *>(buf) + bytes_written,
59 if (status == -1 && errno == EINTR) {
63 PLOG(WARNING) <<
"Failed to write to socket";
67 LOG(WARNING) <<
"Failed to write to socket";
70 bytes_written += status;