Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
K

Kazz

@Kazz
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • mfc: tabbing order..
    K Kazz

    Want half of the hair you just split?

    C / C++ / MFC c++ question

  • mfc: tabbing order..
    K Kazz

    Make sure you have the dialog window pulled up as the formost window > Select 'Layout' (from the top toolbar) > Tab Order > Double click the controls in the tab order you want them.

    C / C++ / MFC c++ question

  • CAsyncSocket problem
    K Kazz

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

    C / C++ / MFC c++ help html debugging performance
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups