End Google Ads 201810 - BS.net 01 --> I have referred to chapter 20 of "teach yourself vc++ + in 21 days by sams " for socket programming using CAsyncSocket class.

I need to understand & implement if the physical connectivity is available or not if "send" command is send. Below is the code snippet.

CString m_strMessage="S";
m_strMessage=m_strMessage+'\x00A';
int iLen = m_strMessage.GetLength();
// Send the message
int iSent = m_sConnectSocket.Send(LPCTSTR(m_strMessage), iLen);
if (iSent == SOCKET_ERROR)
{
AfxMessageBox("Socket Error");
}
else
{
// Sync the variables with the controls
}

It was observed that iSent does not give "SOCKET ERROR" even though Ethernet connection is not available. I need to indicate the user that there is some socket error problem.
I have tried adding below lines of code before send command. But still it does not return correct error code & indicate that the socket connection is not available.

int conn_stat,last_error;

conn_stat= m_sConnectSocket.Connect(m_strName,m_iPort);
last_error= CAsyncSocket::GetLastError();

The last_error remains 0 even if Ethernet cable is removed. Shall I use a timer feature & keep checking if the connection is available or not. If yes, could you help me in achieving this?