I am coding to make UDP communication among computers.
I just take the local port no from the user & create the socket. But, I get the screen with
this message............
TODO: <File description> has encountered a problem and needs to close. We are sorry for the inconvenience.
The debugger does not enter in the if loop also..it goes to if statement execute it & shows that screen.
It is created in the header file of that cpp file.
The application is dialogue based. so <name>dlg.cpp file contains that code & header file contains the declaration of that ptr.
Do you understand what that line is ? It is creation of the OBJECT, if you dont do that, how can you expect it to work ???
So you need to create the CAsyncSocket object there, now about the error, CAsyncSocket class does not take input arguments, you should not pass in the dialog class's pointer there.
Following should work.
Code:
if( (UDPptr = new CAsyncSocket()) == NULL )
{
AfxMessageBox( " Error creating the socket object.." );
}
f ( UDPptr )
{
MessageBox( "Socket Already exists" );
}
else
{
/*if( (UDPptr = new CAsyncSocket(this)) == NULL )
{
MessageBox( " I can reach here too " );
}*/
This logic is incorrect. You should first assign UDPptr to null (in constructor, or somewhere else), then check if it is null and then create a new object and assign to it.
What you are doing is: checking if pointer is non-null, if so display error, else create new one.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.