Reads as many bytes as possible from the read buffer into [begin,end) and returns the number of bytes read (might be 0)
| 1063 | // Reads as many bytes as possible from the read buffer into [begin,end) and returns the number of bytes read (might |
| 1064 | // be 0) |
| 1065 | int read(uint8_t* begin, uint8_t* end) override { |
| 1066 | boost::system::error_code err; |
| 1067 | ++g_net2->countReads; |
| 1068 | size_t toRead = end - begin; |
| 1069 | size_t size = ssl_sock.read_some(boost::asio::mutable_buffers_1(begin, toRead), err); |
| 1070 | g_net2->bytesReceived += size; |
| 1071 | //TraceEvent("ConnRead", this->id).detail("Bytes", size); |
| 1072 | if (err) { |
| 1073 | if (err == boost::asio::error::would_block) { |
| 1074 | ++g_net2->countWouldBlock; |
| 1075 | return 0; |
| 1076 | } |
| 1077 | onReadError(err); |
| 1078 | throw connection_failed(); |
| 1079 | } |
| 1080 | ASSERT(size); // If the socket is closed, we expect an 'eof' error, not a zero return value |
| 1081 | |
| 1082 | return size; |
| 1083 | } |
| 1084 | |
| 1085 | // Writes as many bytes as possible from the given SendBuffer chain into the write buffer and returns the number of |
| 1086 | // bytes written (might be 0) |