MCPcopy Create free account
hub / github.com/MeisApps/pcbu-desktop / GetPacketError

Method GetPacketError

common/src/connection/BaseConnection.cpp:174–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174PacketError BaseConnection::GetPacketError(int result, int error) {
175 if(result == 0)
176 return PacketError::CLOSED_CONNECTION;
177 if(error == SOCKET_ERROR_WOULD_BLOCK || error == SOCKET_ERROR_IN_PROGRESS || error == SOCKET_ERROR_TRY_AGAIN)
178 return PacketError::NONE;
179
180 spdlog::error("Socket operation failed. (Code={}, Str={})", error, strerror(error));
181 if(error == SOCKET_ERROR_CONNECT_REFUSED || error == SOCKET_ERROR_HOST_UNREACHABLE || error == SOCKET_ERROR_CONNECT_ABORTED ||
182 error == SOCKET_ERROR_CONNECT_RESET || error == SOCKET_ERROR_NET_UNREACHABLE)
183 return PacketError::CLOSED_CONNECTION;
184 if(error == SOCKET_ERROR_TIMEOUT)
185 return PacketError::TIMEOUT;
186#ifdef WINDOWS
187 if(error == WSAESHUTDOWN || error == WSAENOTSOCK)
188 return PacketError::CLOSED_CONNECTION;
189#else
190 if(error == EPIPE)
191 return PacketError::CLOSED_CONNECTION;
192#endif
193 return PacketError::UNKNOWN;
194}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected