Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalserial port communication Pin
Anonymous18-Oct-04 13:29
Anonymous18-Oct-04 13:29 
GeneralRe: serial port communication Pin
Murlai18-Oct-04 19:02
Murlai18-Oct-04 19:02 
Generalfile problem Pin
Anonymous18-Oct-04 13:12
Anonymous18-Oct-04 13:12 
GeneralRe: file problem Pin
RobJones18-Oct-04 13:14
RobJones18-Oct-04 13:14 
GeneralRe: file problem Pin
Azghar Hussain18-Oct-04 19:01
professionalAzghar Hussain18-Oct-04 19:01 
GeneralRe: file problem Pin
Murlai18-Oct-04 19:26
Murlai18-Oct-04 19:26 
GeneralException handling Pin
RobJones18-Oct-04 13:09
RobJones18-Oct-04 13:09 
GeneralRe: Got a little further.. but still need help Pin
RobJones18-Oct-04 17:40
RobJones18-Oct-04 17:40 
I found a article on another site that talked about my problem.. here is a little blurb from the article...

If the terminating socket has been closed, calling Flush on the CArchive will raise an exception (so will calling Close). In the previous case, before the exception is handled, CArchive goes out of scope and its destructor calls Close. Close throws another exception and all hell breaks loose. Never throw exceptions from destructors.

You will need nested try / catch blocks ... [Article^]

My problem with the exceptions is fixed but I still have a memory leak.. Any ideas??

// Some function calls OnSend passing it a pointer to the socket
// and a string to send..
void CMainFrame::OnSend(CClientSocket *pSocket, CString strMsg)
{
	if(*pSocket != INVALID_SOCKET)
	{
		try
		{
			sendObject(pSocket, strMsg);
		}
		catch (CException* pEx)
		{
			pEx->Delete();
		}
	}
}

BOOL CMainFrame::sendObject(CClientSocket *pSocket, CString strMsg)
{	
	BOOL bRet = TRUE;
	
	CSocketFile sf(pSocket);
	CArchive ar_send(&sf, CArchive::store);

	try
	{
		// Send the data
		ar_send << strMsg;
		ar_send.Flush();
		ar_send.Close();
		sf.Close();
	}
	catch (CException* pEx)
	{
		bRet = FALSE;
		pEx->Delete();
	}

	return bRet;
}


Whoever said nothing's impossible never tried slamming a revolving door!
Generali need help!!!!!!! Pin
DaBlueSage18-Oct-04 13:00
DaBlueSage18-Oct-04 13:00 
GeneralRe: i need help!!!!!!! Pin
l a u r e n18-Oct-04 15:25
l a u r e n18-Oct-04 15:25 
GeneralRe: i need help!!!!!!! Pin
bryce18-Oct-04 20:39
bryce18-Oct-04 20:39 
GeneralConversion between multibyte and UNICODE Pin
Vancouver18-Oct-04 12:32
Vancouver18-Oct-04 12:32 
GeneralRe: Conversion between multibyte and UNICODE Pin
l a u r e n18-Oct-04 15:26
l a u r e n18-Oct-04 15:26 
GeneralRe: Conversion between multibyte and UNICODE Pin
Vancouver18-Oct-04 15:50
Vancouver18-Oct-04 15:50 
GeneralRe: Conversion between multibyte and UNICODE Pin
PJ Arends18-Oct-04 16:09
professionalPJ Arends18-Oct-04 16:09 
GeneralRe: Conversion between multibyte and UNICODE Pin
Vancouver18-Oct-04 17:54
Vancouver18-Oct-04 17:54 
GeneralRe: Conversion between multibyte and UNICODE Pin
PJ Arends19-Oct-04 5:21
professionalPJ Arends19-Oct-04 5:21 
GeneralRe: Conversion between multibyte and UNICODE Pin
Vancouver19-Oct-04 6:15
Vancouver19-Oct-04 6:15 
GeneralCopy Constructor Pin
Malcolm Smart18-Oct-04 10:46
Malcolm Smart18-Oct-04 10:46 
GeneralRe: Copy Constructor Pin
David Crow18-Oct-04 11:18
David Crow18-Oct-04 11:18 
GeneralRe: Copy Constructor Pin
Malcolm Smart18-Oct-04 11:37
Malcolm Smart18-Oct-04 11:37 
GeneralRe: Copy Constructor Pin
David Crow18-Oct-04 16:16
David Crow18-Oct-04 16:16 
GeneralWM_CLOSE message Pin
help_wanted18-Oct-04 9:10
help_wanted18-Oct-04 9:10 
GeneralRe: WM_CLOSE message Pin
David Crow18-Oct-04 9:19
David Crow18-Oct-04 9:19 
GeneralRe: WM_CLOSE message Pin
help_wanted18-Oct-04 9:35
help_wanted18-Oct-04 9:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.