|
Nick Usechak wrote: 2. I am unfamiliar with basic_ofstream? Could you point me somewhere?
ofstream is nothing more than a typedef for basic_ofstream<char>, so you are already familiar with basic_ofstream. Using the int template (instead of char) will allow you to avoid casting it to char* and using sizeof in the read/write calls.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Nick Usechak wrote: ...but the data is not written to the file (or at least not properly).
How are you verifying this? You'll find that the file is being written correctly, but when you later go to read from it, that's where the problem is at. Leaving the file open, and then trying to open it again elsewhere is where you should focus.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks David,
First day stuff, man... Well that solved the problem I was asking about. I am no longer sure if it was the real problem that I was having, since I closed the file in the class destructor. But I should be able to figure it out from here.
|
|
|
|
|
Hello all. my apoligies if this is not the correct forum for my question. I'm new to this. I'm trying to deduce a solution to a few errors poping up in a app used in WinXP. The apps name is Conmain (also known as Clasp32)
Beneath the conmain.exe error once dwwin.exe in Watson from registry is disabled are the true culprits:
Exception EAccessViolation in module Conmain.exe at 000034BC Access violation at address 004034BC in module 'conmain.exe' Read of address C08BC300
closing that error window will crash the Clasp32. This error is always the same.
Exception EWin32 Error in module Conmain.exe at 0000F130.Win32 Error Code:5. Access is denied.
Howerver does not crash Clasp32 when error window closed..
The instruction at "0x004570bd" referenced memory at "0x05cd11c0" The memory could not be read.
these numbers change each time the error is displayed. Howerver does not crash Clasp when error window closed.
Runtime error 216 at 000053344
Last error window always the same, again closing error window does not crash clasp32
These occour in the order posted. Once apprxmtly every 7 -20 openings of the application. Not predictably.
Any , I mean any help here would be greatly appreciated. I'm outta my element when it comes to these kinda problems.
Thanks everyone !
Robert.
-- modified at 16:00 Thursday 12th October, 2006
|
|
|
|
|
We're glad to help, but these forums are for help with programs you are writing. Your post sounds like you have issues running a program someone else wrote ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Fellow Metaler , eh?
http://www.meatlockerseven.com/
Last metal band I produced. Thanks and yeah someone else wrote it. I was hoping for a little tip or two on error resolution. I'm no expert at this - Pro-Tools and 2'' analog yes. WinXP errors no
Robert.
|
|
|
|
|
hotari wrote: Fellow Metaler , eh?
Yep - seeing Iron Maiden in 4 days !!!
hotari wrote: http://www.meatlockerseven.com/
Cool - I wll check it out.
hotari wrote: I was hoping for a little tip or two on error resolution.
Issue is, if you didn't write it, I'm not sure what you can do, and I'm sure there are better places to ask for help. That is, places where people are focused on this sort of problem.
I saw you got other replies, I hope they helped. If they didn't, I'd recommend contacting the authors first, then looking for a forum more focused on this sort of problem.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yikes!
If you know who wrote it, ask them to fix it
7 out of 20 isn't bad. I generally use the 50% rule...if it works every other time, ship it!
Mark
|
|
|
|
|
Cheers! The writer is in Budapest and I have a language barrier. That and he's done zip in over 2 yrs to resolve these issues and my employer/reseller asked if there was anything I could do to at least get the ball rolling in a positive direction.My main tasks are insuring the hardware interface is functioning but these errors task me. fair enough.
Robert.
|
|
|
|
|
hotari wrote: The writer is in Budapest and I have a language barrier. That and he's done zip in over 2 yrs to resolve these issues
Well that is most unfortunate! It sounds like it needs some serious debugging...some pointer "issues" I suppose
Mark
|
|
|
|
|
Can you recomend a few steps , I as a newbie could take to move this situation forward in debugging?
Very appreciative ,
robert.
|
|
|
|
|
If you have access to the source code you can build a debug version and run it in the debugger.
Then when it crashes you'll at least see what line of code is causing it. Then it's a matter
of "Is it just that line or a result of something(s) executed before that line?" To do this
requires knowledge of the language it's written in, knowledge of the platform (Windows, DOS, Unix,
etc.) it's running on, etc. This is the a job of the programmer Memory
faults like this are unacceptable IMO (I was joking about the 50% rule haha) for (at least) one
obvious reason - the program stops running.
Mark
|
|
|
|
|
Ok . Thank you. I'd be happy if the errors would at least be invisible as the app still runs provided the first error window isn't closed. Not sure if thats even realistic though. Believe me, it started at only 50% a few years ago
|
|
|
|
|
Do you have soruce code and if yes did you use of debugger?
|
|
|
|
|
After speaking with the writer , in half english , broken Hungarian on my part , I suspect , and no I don't have source , The debugger app may pose a language issue. Are debuggers English heavy in their operation ?
Here's the writers response to the error codes I found:
I can not to fix it.
It is a windows memory problem.
Our computer memory is 1 GB, and sometimes happend this error message.
I do not know why, I have not idea how can I fix it.
Sorry.
-- modified at 18:23 Friday 20th October, 2006
|
|
|
|
|
Hi there,
I am using TCP/IP socket to connect two aplications to each other that exchange too many messages (sending, receiving, and Acking on them) sometimes there are many messages in one TCP packet going through the socket and as a result, when one application receives too many messages appended to each other in one receiving packet, it can not handle the messages properly. Is there any way to prevent this problem (having too many messages in one TCP packet). when the trafic is not very busy, there is just one message per packt going through the socket at a time but as I mentioned, sometimes there are many messages appended to each other in one packet that receives at once.
I apreciate any help.
Best regards,
|
|
|
|
|
TCP/IP is stream oriented, not packet. If you want packets it's up to you to break the stream
into packets. If you send a "packet" on a TCP/IP socket there's no guarantee you will get a
full "packet" in one recv at the other end. You need to poll or wait for FD_READ notifications
on the receiving end until you receive all the bytes making up an entire "packet", handle the
message, and repeat.
How are you handling reading and writing the socket? Separate thread? FD_READ notifications
through an HWND? Have you messed with the send/receive buffer sizes or any other socket settings?
Post an example I'll try to help
Mark
|
|
|
|
|
Here is one example of my XML string comming in one single receiving data: as you can see each time I receive one Message, it should start with time and then the start of string which is WEResp or WESend or Recv and after that the whole string should come by ending string that would be . when the trafic is not very busy I receive the string like that but sometimes I receive many strings appended to each other and as you mentioned, some times it goes beyond my buffer size in which I would lose information. What my code does is that using a thread, reads the info and put it in a buffer and then parse it and sends it down to another application.
Oct 07 11:03:53.359 i: : <weresp id="128"><deviceid>210<groupid>1<msgtype>5<flags>144<status>S<responsecode>2
<wesend id="115"><deviceid>87<groupid>1<priority>0<msgtype>3<flags>128<datalen>50000030805<status>N<wesend id="130"><deviceid>232<groupid>1<priority>1<msgtype>5<flags>128<datalen>3000200<status>N<wesend id="131"><deviceid>232<groupid>1<priority>1<msgtype>5<flags>128<datalen>3000200<status>N<wesend id="132"><deviceid>41<groupid>1<priority>0<msgtype>3<flags>128<datalen>50000030804<status>N<wesend id="149"><deviceid>167<groupid>1<priority>0<msgtype>3<flags>128<datalen>1000000106030000660101<status>N<wesend id="58"><deviceid>
Oct 07 11:03:53.468 o: : 181<groupid>1<priority>0<msgtype>1<flags>128<datalen>150001480C0301010000060106010B05<status>N<wesend id="63"><deviceid>181<groupid>1<priority>0<msgtype>32<flags>128<datalen>21308<status>N<wesend id="66"><deviceid>181<groupid>1<priority>0<msgtype>5<flags>128<datalen>1100001083130382C2048414E53454E204E4F5254482072642C2042524D50544E0D0A0D0A444553542E2E2E0D0A4252414D414C45412042415054495354204348555243480D0A393035302C2044495849452072642C202320432C2042524D50544E0D0A0D0A5452583D303432333436<status>N<wesend id="72"><deviceid>87<groupid>1<priority>0<msgtype>3<flags>128<datalen>50000030805<status>N<wesend id="74"><deviceid>232<groupid>1<priority>0
thanks for the help.
|
|
|
|
|
The easiest thing to do is tack a header structure (fixed-length) on to each packet you send.
I'll call it MYPACKETHEADER.
On the receive end read sizeof(MYPACKETHEADER) bytes. In that header structure should be a
datalength variable (an int, DWORD, WORD, whatever is appropriate). When you've received
an entire header, read the datalength and now you know how many bytes to read to get the entire
packet.
The way you are doing it now you need to read smaller chunks and parse as you go. Just reading
until there's no more to receive is not good idea (buffer overflow as you mentioned)
Can you post an example of the code you are using to receive from the socket?
Mark
|
|
|
|
|
As mentioned previously TCP provides a stream and you must never rely on data received to be in the same "chunks" as you send them away, you may get multiple chunks at once or possibly only the first bytes of a chunk. In brief this means: collect data coming in and split it up, for example use a text delimiter like a newline between each of your XML strings.
Hope it helps.
/M
|
|
|
|
|
anyone can help me to explain this process step- by- step?
struct list_ele *<br />
sortfun( struct list_ele *list )<br />
{<br />
<br />
int exchange;<br />
struct list_ele *nextp, *thisp, dummy;<br />
<br />
dummy.pointer = list;<br />
do{<br />
exchange = 0;<br />
thisp = &dummy;<br />
while( (nextp = thisp->pointer)<br />
&& nextp->pointer){<br />
if(nextp->data < nextp->pointer->data){<br />
<br />
exchange = 1;<br />
thisp->pointer = nextp->pointer;<br />
nextp->pointer =<br />
thisp->pointer->pointer;<br />
thisp->pointer->pointer = nextp;<br />
}<br />
thisp = thisp->pointer;<br />
}<br />
}while(exchange);<br />
<br />
return(dummy.pointer);<br />
}<br />
~~~@@@###EZRA###@@@~~~
|
|
|
|
|
It's ordering a linked list.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
It is ordering a linked-list using a bubble sort.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Q1
We want to store the information about a student. This information includes student’s name, address and roll number. What data type (either built in or user defined) should be used to store all this information in a single variable.
Also we want to store the marks obtained of a student. The marks can be of type integer, character or float. We have to store the student’s marks in a variable of a particular data type. What data type (either built in or user defined) should be used to handle such a wide range of values.
Q2
As we know that in a windows application whenever a key is pressed, a message is sent to the active window. We are developing a DOS based application and want to detect whenever a key is pressed from keyboard. How can we do so?
Q3
We are writing a DOS based application in which we have to display the system date and time. Write down the code for doing so.
Shehwar
|
|
|
|
|
Double posting homework questions isn't likely to get you any answers.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|