?
Solved

C++ "-858993460" value received when reading api receive buffer

Posted on 2011-04-26
17
Medium Priority
?
859 Views
Last Modified: 2012-05-11
Dear Experts,

I have the following error:

Whenever I attempt to send a structured message through TCP on my program, I receive the following error (please see screen shot below).
Error C++ '-858993460'
I am due to hand in this piece of c++ networking coursework soon, and would like to be able to send and receive messages/ integer values. This error is extremely confusing, and therefore I am asking for your assistance.

Kind Regards...
0
Comment
Question by:SME_Paddington
  • 8
  • 4
  • 4
  • +1
17 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 35470299
It would be useful if you could post the code that caused this output.
0
 

Author Comment

by:SME_Paddington
ID: 35470487
I would have to post it as a password protected file, due to possible plagiarism etc. of my code.  [As uploads are publicly viewable]. This is the main reason why I have not posted any source code on EE.

Please email me for a copy at: **** email address removed -- thermoduric EE mod.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 35470509
Can you at least post the relevant part of the code that caused this output ?

Or a code sample that has the same problem ?

Otherwise it's quite difficult to help :) Note that communicating via email is not allowed on EE.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 53

Expert Comment

by:Infinity08
ID: 35470517
(you also might want to ask a moderator to remove your e-mail address from your post - in order to avoid spam ;) - you can click the "Request Attention" button for that)
0
 
LVL 32

Expert Comment

by:phoffric
ID: 35470519
-858993460 decimal = 0xFFFFFFFFCCCCCCCC
If running in VS Debug mode, this value can be a debug indicator of an uninitialized variable on the stack. So, I would start looking for variables (or arrays) that are used without prior being set.
0
 

Author Comment

by:SME_Paddington
ID: 35470547
Please note, that this thread will be deleted after a solution is given.

Also, I know my coding isn't amazing - but it sort of works.

Kind Regards


***
*** Original code replaced with a suitable analogue - thermoduric, EE Moderator
*** http://www.experts-exchange.com/Community_Support/General/Q_26979092.html
***
// line 707 onwards

Message_PDU Message;
m_CSimpleServer_TCP.InitialiseCommunication_ServerSide();
//CSimpleServer_TCP().ReadMessageFromReceiveBuffer();

//Dangerous Code
/*
Message_PDU ReceivedMessage;	// 'ReceivedMessage' is a local instance of the 'Message_PDU' structure
m_CSimpleServer_TCP.InitialiseCommunication_ServerSide();
ReceivedMessage = m_CSimpleServer_TCP.ReadMessageFromReceiveBuffer();
cout << "Message received: \"" << ReceivedMessage.szMessageText << "\" Message number:" << ReceivedMessage.iMessageNumber << endl << endl;
*/

//Testing
char testing = 'y';
while (testing != 'n' && testing != 'N')
{
   cout << "\n Wait a moment, lets check for a message (Y/N): ";
   cin >> testing;
   cout << "\n\n" << Message.szMessageText << (int) Message.iMessageNumber << endl;
}

Open in new window

0
 

Author Comment

by:SME_Paddington
ID: 35470567
@infinity08

I do not know how to request attention on here/ I cannot see the option.

You want code? Here it is.

@all

Please note, there are other files to this code, and if you would like me to include their coding, please let me know. (Small header files, etc.)

Kind Regards
0
 

Author Comment

by:SME_Paddington
ID: 35470577
If anyone else can see flaws within my coding, please feel free to rectify them and I will be happy to include you as part of the solution.

Thanks Experts
0
 
LVL 32

Accepted Solution

by:
phoffric earned 1332 total points
ID: 35470600
In main line 707: Message_PDU Message;
Message is a local variable on the main stack.
You then use it at line 725: cout << "\n\n" << Message.szMessageText << (int) Message.iMessageNumber << endl;

Perhaps you have a Message variable defined elsewhere that is being hidden by the local variable, Message.
0
 
LVL 32

Assisted Solution

by:phoffric
phoffric earned 1332 total points
ID: 35470615
I forgot to emphasize that this is an example of using a variable that has not been set. So set Message to what you want before using it.

If you ran this in Release Mode, you probably will get junk, but not get the 0xFFFFFFFFCCCCCCCC. In debug mode, this extra special initialization is provided for you as a courtesy of Microsoft VS to help you debug such memory related issues.
0
 

Author Comment

by:SME_Paddington
ID: 35470637
@phoffric

How could I rectify this? - I will post the codes of the remaining header files so you can see them yourself:

***
*** Original code replaced with a suitable analogue - thermoduric, EE Moderator
*** http://www.experts-exchange.com/Community_Support/General/Q_26979092.html
***


struct Message_PDU 
{
   char Message_PDU::szMessageText[101];
   int iMessageNumber;
};

Open in new window

0
 
LVL 32

Expert Comment

by:phoffric
ID: 35470777
You have to first receive a message to prevent use without set. I have an outdoors appointment now so I'll be gone for a few hours. Taking advantage of the sun before the next 72 hours of thunderstorms hit. If you need assistance on your application, then I recommend asking another question. I'll be able to take a look at your header file tomorrow.
0
 

Author Comment

by:SME_Paddington
ID: 35470837
@phoffric

Okay, Thank you very much for your assistance so far.
0
 

Author Comment

by:SME_Paddington
ID: 35470980
This comment requires deletion by a moderator by 12pm GMT on 28/04/2011.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 35470981
>> I do not know how to request attention on here/ I cannot see the option.

There should be a button labelled "Request Attention" - near the question you asked.
0
 
LVL 35

Assisted Solution

by:sarabande
sarabande earned 668 total points
ID: 35474732
SME_Paddington, was your problem solved?

as far as i see phoffric was right and the issue you have about the output is cause you never received a message (the receiving code was commented and uses variable 'ReceiveMessage') but in your output statement you used 'Message'. i would assume the 'Message' simply has some garbage not initialized (you could verify that by adding a default constructor to struct Message_PDU which initialize the char array 'szMessageText' and the int 'iMessageNumber').

Sara
0
 

Author Closing Comment

by:SME_Paddington
ID: 35474967
Thanks, guys and girls for your input.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question