HyperEngineer
Programmer
I have the following code in a class:
Code:
bool CTelnetDlg::ErrorMessage(CString cError)
{
m_cErrorStatus = cError;
UpdateData(false);
return 0;
}
When I call this code from within the class it works fine. But if I call it from another class the UpdateData(false); gives me an error.
Code from within the class that is in the OnInitDialog() function:
Code:
CString cErrMsg;
if (WSAStartup(MAKEWORD(2,2), &wd))
{
cErrMsg = "WSAStartup failed";
ErrorMessage(cErrMsg);
}
else
{
cErrMsg = "WSAStartup successful";
ErrorMessage(cErrMsg);
}
Code:
CSocketDx::CSocketDx(char *strIP,int nPort)
{
unsigned long ip;
CTelnetDlg ErrorMessage;
CString cErrMsg;
if((*strIP <= '9') && (*strIP >= '0'))
{
if((ip = inet_addr(strIP)) == INADDR_NONE)
{
cErrMsg = "DX invalid host IP given";
ErrorMessage.ErrorMessage(cErrMsg);
}
else
{
cErrMsg = "DX valid host IP given";
ErrorMessage.ErrorMessage(cErrMsg);
}
}
else
{
hostent* ent = gethostbyname(strIP);
if(!ent)
{
ErrorMessage.ErrorMessage("DX Host IP error");
}
else
{
ErrorMessage.ErrorMessage("DX Host IP valid");
}
ip = *(unsigned long*)(ent->h_addr);
}
m_sockaddr_in.sin_family = AF_INET;
m_sockaddr_in.sin_port = htons(nPort);
m_sockaddr_in.sin_addr = *(in_addr*)&ip;
}
The error code is:
Code:
Debug assertion failed!
Program: \telnet\debug\telnet.exe
File: wincore.cpp
Line: 3095
...
When I debug it I can see the CString coming in. It looks OK no matter where it is called from. But the UpdateData() function is not happy. Why?
HyperEngineer
If it ain't broke, it probably needs improvement.