MCPcopy Create free account
hub / github.com/Beckhoff/ADS / read

Method read

AdsLib/Sockets.cpp:169–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169size_t Socket::read(uint8_t *buffer, size_t maxBytes, timeval *timeout) const
170{
171 if (!Select(timeout)) {
172 return 0;
173 }
174
175 const auto msvcMaxBytes = static_cast<int>(
176 std::min<size_t>(std::numeric_limits<int>::max(), maxBytes));
177 const int bytesRead = recv(m_Socket, reinterpret_cast<char *>(buffer),
178 msvcMaxBytes, 0);
179 if (bytesRead > 0) {
180 return bytesRead;
181 }
182 const auto lastError = WSAGetLastError();
183 if ((0 == bytesRead) || (lastError == CONNECTION_CLOSED) ||
184 (lastError == CONNECTION_ABORTED)) {
185 throw std::runtime_error("connection closed by remote");
186 } else {
187 LOG_ERROR("read frame failed with error: "
188 << std::dec << std::strerror(lastError));
189 }
190 return 0;
191}
192
193Frame &Socket::read(Frame &frame, timeval *timeout) const
194{

Callers 3

RunRawFunction · 0.80
SendRecvFunction · 0.80
ReceiveMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected