How to receive error on TCP socket?

I have tcp client socket created by

FSocket* Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(NAME_Stream, ListenName, false);
Socket->Connect(*addr);
ConnectionSocket = Socket;

Inside thread which read and send data I also tried to receive error by this way:

if (ConnectionSocket->GetConnectionState() == ESocketConnectionState::SCS_ConnectionError)
{
    bErrorReceived = true;
}

But this fires only if remote server is turned down. If I manually turn down the working server with connected server, this code not fires (I would like to see “Remote server forcibly closed connection”).

In socket API I found the bool SetRecvErr(bool), but I find no use…

I also faced the issue. In case someone else also has the issue, error can be retrieved via:

ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
ESocketErrors ErrorCode = SocketSubsystem->GetLastErrorCode();
FString ErroCodeAsString = FString(SocketSubsystem->GetSocketError(ErrorCode));