Stack error for char array

Discussion in 'C++' started by arupsarkar, May 31, 2011.

  1. arupsarkar

    arupsarkar New Member

    Joined:
    Aug 17, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hi:

    I have a socket client running which has a char array of size 512 mentioned. I have a loop to receive the message from the server, when the loop exits I am getting the following error.

    Environment:
    Windows 64bit.
    VS 2010

    Run-Time check failure #2 - Stack around the variable 'recMessage' was corrupted.

    Code:
    int STRLEN = 512;
    char recMessage[STRLEN] = "0";
    ClientSocket sockClient;
    
    sockClient.ConnectToServer( ipAddress.c_str(), port );
    sockClient.SendData("L|100=some_value;101=some_value\n");
    sockClient.RecvData( recMessage, STRLEN );
    
    int counter = 0
    while(counter <= 10){
    
    	sockClient.RecvData( recMessage, STRLEN );
    	cout << recMessage << endl;
    	counter++;
    }
    
    memset(recMessage,0,sizeof(char)*STRLEN);
    sockClient.CloseConnection();
    
    
     
  2. arupsarkar

    arupsarkar New Member

    Joined:
    Aug 17, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Just wanted to confirm that the message I am receiving from the server is less than 200 characters in length.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice