aboutsummaryrefslogtreecommitdiffstats
path: root/util/network/sock.h
diff options
context:
space:
mode:
authorlapshov <lapshov@yandex-team.ru>2022-02-10 16:49:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:39 +0300
commit1ef52da9919aaa7ec7e3c51da7fdaa637ab133b7 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/network/sock.h
parent4f36f44b1e216dca1f44ada8d126e7b70f05da2f (diff)
downloadydb-1ef52da9919aaa7ec7e3c51da7fdaa637ab133b7.tar.gz
Restoring authorship annotation for <lapshov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/network/sock.h')
-rw-r--r--util/network/sock.h80
1 files changed, 40 insertions, 40 deletions
diff --git a/util/network/sock.h b/util/network/sock.h
index bfc23cc996..b10be2f715 100644
--- a/util/network/sock.h
+++ b/util/network/sock.h
@@ -534,7 +534,7 @@ public:
{
}
};
-
+
class TInet6StreamSocket: public TStreamSocket {
public:
TInet6StreamSocket(SOCKET fd)
@@ -549,60 +549,60 @@ public:
};
class TStreamSocketInput: public IInputStream {
-public:
+public:
TStreamSocketInput(TStreamSocket* socket)
- : Socket(socket)
- {
- }
+ : Socket(socket)
+ {
+ }
void SetSocket(TStreamSocket* socket) {
- Socket = socket;
- }
-
-protected:
+ Socket = socket;
+ }
+
+protected:
TStreamSocket* Socket;
-
+
size_t DoRead(void* buf, size_t len) override {
Y_VERIFY(Socket, "TStreamSocketInput: socket isn't set");
- const ssize_t ret = Socket->Recv(buf, len);
-
- if (ret >= 0) {
- return (size_t)ret;
- }
-
+ const ssize_t ret = Socket->Recv(buf, len);
+
+ if (ret >= 0) {
+ return (size_t)ret;
+ }
+
ythrow TSystemError(-(int)ret) << "can not read from socket input stream";
- }
-};
-
+ }
+};
+
class TStreamSocketOutput: public IOutputStream {
-public:
+public:
TStreamSocketOutput(TStreamSocket* socket)
- : Socket(socket)
- {
- }
+ : Socket(socket)
+ {
+ }
void SetSocket(TStreamSocket* socket) {
- Socket = socket;
- }
-
+ Socket = socket;
+ }
+
TStreamSocketOutput(TStreamSocketOutput&&) noexcept = default;
TStreamSocketOutput& operator=(TStreamSocketOutput&&) noexcept = default;
-protected:
+protected:
TStreamSocket* Socket;
-
+
void DoWrite(const void* buf, size_t len) override {
Y_VERIFY(Socket, "TStreamSocketOutput: socket isn't set");
-
+
const char* ptr = (const char*)buf;
- while (len) {
- const ssize_t ret = Socket->Send(ptr, len);
-
- if (ret < 0) {
+ while (len) {
+ const ssize_t ret = Socket->Send(ptr, len);
+
+ if (ret < 0) {
ythrow TSystemError(-(int)ret) << "can not write to socket output stream";
- }
-
+ }
+
Y_ASSERT((size_t)ret <= len);
- len -= (size_t)ret;
- ptr += (size_t)ret;
- }
- }
-};
+ len -= (size_t)ret;
+ ptr += (size_t)ret;
+ }
+ }
+};