Click here to Skip to main content
15,902,112 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWhat is wrong with these SQL statements?? Pin
IrishSonic8-Feb-03 0:26
IrishSonic8-Feb-03 0:26 
AnswerRe: What is wrong with these SQL statements?? Pin
vin8-Feb-03 1:08
vin8-Feb-03 1:08 
AnswerRe: What is wrong with these SQL statements?? Pin
Ted Ferenc8-Feb-03 4:42
Ted Ferenc8-Feb-03 4:42 
GeneralHere is my code... Pin
IrishSonic8-Feb-03 7:35
IrishSonic8-Feb-03 7:35 
GeneralRe: Here is my code... Pin
Ted Ferenc8-Feb-03 10:09
Ted Ferenc8-Feb-03 10:09 
GeneralRe: Here is my code... Pin
Kelly Herald9-Feb-03 18:02
Kelly Herald9-Feb-03 18:02 
AnswerRe: What is wrong with these SQL statements?? Pin
JockeP9-Feb-03 6:08
JockeP9-Feb-03 6:08 
GeneralCAsyncSocket problem Pin
Kazz7-Feb-03 23:08
Kazz7-Feb-03 23:08 
Hi, I just started getting into C++/MFC and I've hit my first snag. I'm making a simple program that downloads the contents of a webpage and then sorts out href's. The problem comes into play in the OnReceive event handler. I'm getting 'The instruction at 0x77f475cc referenced by 0x0000000. The memory could not be "written"' right after I get the first packet. I suppose I'm doing something wrong with a pointer? Null maybe? It ONLY does this when I compile for release, it works perfectly when I compile for debug. After changing around some compiler options (turning off optimizations) it still does the same thing. I've done step by step debugging and the last thing I'm seeing is 'Receiving HTML'. I've looked over it for a long time and even showed it to a few friends, they couldn't figure it out either. My guess is it's the pBuf pointer but I don't see why, if anybody could give me some tips I would appreciate it! Here's my code..

void CReconDlg::OnReceive()<br />
{<br />
	char *pBuf = new char[1024];<br />
	CString strRecvd, strConlen = "Content-Length:", actualLen;<br />
	char *pConlen;<br />
        int wholePacket, int result, int lenLen, int endPos, int iBufSize = 1024, int iRcvd, int packetStart;<br />
<br />
        // get the data<br />
	iRcvd = m_sConSocket.Receive(pBuf, iBufSize);<br />
        // strip any garbage off of the buffer<br />
	pBuf[iRcvd] = NULL;<br />
<br />
	// error trap<br />
	if (iRcvd == SOCKET_ERROR){<br />
		MessageBox("Error on receiving socket");<br />
	}else{<br />
                // debug step and append buffer to CString for manipulation<br />
		m_sStat = "Receiving HTML..";<br />
		strRecvd += pBuf;<br />
	}<br />
	<br />
        // search for the Content-Length so we know just how much data we're getting<br />
	pConlen = strstr(strRecvd, strConlen);<br />
	<br />
        // if it's found parse out the Content-Length: header feild and append everything AFTER the header to a new string<br />
	if (pConlen != NULL){<br />
		result = (int)(pConlen - strRecvd + 1) + 15;<br />
		endPos = strRecvd.Find("\n", result) - 1;<br />
		lenLen = (endPos - result);<br />
		actualLen = strRecvd.Left(endPos);<br />
		realLen = actualLen.Right(lenLen);<br />
		packetStart = strRecvd.Find("\r\n\r\n", result);<br />
		int packetLen1 = (strlen(strRecvd) - packetStart);<br />
		m_strIn += strRecvd.Right(packetLen1);<br />
	}else{<br />
                // if there's no header just throw the entire string onto our 'raw packet'<br />
		m_strIn += strRecvd;<br />
	}<br />
                // get lengths<br />
		wholePacket = strlen(m_strIn) - 4;<br />
		CString display ;<br />
		display.Format("%d", wholePacket);<br />
		<br />
        // have we got all of it? if so continue to parse..<br />
	if (realLen == display){<br />
		m_sStat = "Received entire packet, parsing..";<br />
		ParseString(m_strIn);<br />
		m_sConSocket.Close();<br />
		m_strIn = "";<br />
		realLen = "";<br />
		<br />
	}<br />
	<br />
	UpdateData(FALSE);<br />
<br />
}

GeneralRe: CAsyncSocket problem Pin
Michael Dunn8-Feb-03 7:32
sitebuilderMichael Dunn8-Feb-03 7:32 
Generalhelp: odbc error:field data truncated during data fetch Pin
trustno17-Feb-03 21:23
trustno17-Feb-03 21:23 
Generalvc sdk Pin
Ashwin C7-Feb-03 21:10
Ashwin C7-Feb-03 21:10 
GeneralRe: vc sdk Pin
Philip Patrick7-Feb-03 21:53
professionalPhilip Patrick7-Feb-03 21:53 
Questionhow to get size of any control Pin
TSrinivasR7-Feb-03 20:44
TSrinivasR7-Feb-03 20:44 
GeneralVery Urgent-Downloading files from internet Pin
vcarivu7-Feb-03 20:41
vcarivu7-Feb-03 20:41 
GeneralRe: Very Urgent-Downloading files from internet Pin
Ted Ferenc7-Feb-03 21:47
Ted Ferenc7-Feb-03 21:47 
GeneralRe: Very Urgent-Downloading files from internet Pin
Michael Dunn8-Feb-03 7:33
sitebuilderMichael Dunn8-Feb-03 7:33 
GeneralKill Process Pin
suresh_sathya7-Feb-03 20:22
suresh_sathya7-Feb-03 20:22 
GeneralRe: Kill Process Pin
includeh108-Feb-03 1:31
includeh108-Feb-03 1:31 
GeneralExe optimization Pin
suresh_sathya7-Feb-03 20:22
suresh_sathya7-Feb-03 20:22 
GeneralRe: Exe optimization Pin
Mike Nordell8-Feb-03 7:09
Mike Nordell8-Feb-03 7:09 
GeneralUpgrading DLL at Booting time-VERY URGENT Pin
vcarivu7-Feb-03 19:30
vcarivu7-Feb-03 19:30 
GeneralRe: Upgrading DLL at Booting time-VERY URGENT Pin
Ted Ferenc7-Feb-03 21:44
Ted Ferenc7-Feb-03 21:44 
GeneralVoice Recording Pin
Chintan7-Feb-03 18:50
Chintan7-Feb-03 18:50 
GeneralRe: Voice Recording Pin
TSrinivasR7-Feb-03 20:47
TSrinivasR7-Feb-03 20:47 
GeneralRe: Voice Recording Pin
Chintan18-Feb-03 18:14
Chintan18-Feb-03 18:14 

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.