This is where I attempt to send the HTTP request.
class CIrrigationHTTPSocket is derived from CAsyncSocket, and I am simply calling the ::Connect(...) function.
But it generates the error "This socket has not been bound with Bind or is already connected." but I have no idea what this means or how to resolve it.
bool CIrrigationHTTPSocket::Send(LPCSTR lpszData)
{
int nResult = 0;
CString strData;
int nLength = 0;
if (m_strDestIPAddr.GetLength() > 0)
{
if (!m_strPassword.IsEmpty())
strData = CString("windows") + m_strDelim + m_strPassword + m_strDelim + lpszData + m_strDelim;
else
strData = CString("windows") + m_strDelim + lpszData + m_strDelim;
encodeBase64(strData);
strData = m_strDestIPAddr + "/" + strData;
nLength = strData.GetLength();
m_nTimeoutTrigger = GetTickCount() + m_nWait;
if (!Connect(strData, 80))
{
DisplayError(GetLastError());
nResult = 0;
}
}
return nResult > 0;
}
This is how I have setup this socket:
bool CIrrigationHTTPSocket::Create()
{
BOOL bResult = CAsyncSocket::Create();
if (!bResult)
DisplayError(GetLastError());
Initialise();
if (!Bind(m_nLocalListenPort, m_strLocalIPAddr))
DisplayError(GetLastError());
return bResult == TRUE;
}