|
Hey all,
I'm sending a large number of JPGs in a sequence over a LAN via a socket. I'm getting the data across the wire no problem. The problem is, all my files are getting broken during transmission, and I don't know how to reassemble them. For them to get broken up is only natural b/c of the underlying network system... So, how can I reassemble my files on the other end of the wire??
|
|
|
|
|
Well... are you using TCP or UDP?
UDP has no connection or flow control. It simply sends data and if the data gets lost, there is no way of getting it back. Packets might even "switch" position during transit.
TCP has builtin functionality to prevent packet loss during network transit. That means, if you sent something over the network with TCP, every byte WILL arrive (in your app) in the same order it was sent - or you get an exception because the connection was lost without proper "FIN"-procedure.
If you ARE using TCP, your software is doing something wrong because with TCP, lost packages can't happen (with the usual exceptions of connection loss and exploding power supplies etc.)
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Ah.. perhaps my first explanation was poor.
I am using TCP. I am not losing any packets. I just need a way to deliniate between the end of one file and the beginning of another. If memory serves (its been a long time since my networking course..) I need to be using a protocol of some sort?
SO... I guess i'm asking what's the best way to go implementing a protocol in the application layer, or is this even the correct approach??
Thx!
|
|
|
|
|
i need to create a matrix that contain an integer value 1-7, another integer value 1-20, and 24 chars.
How can i struct this matrix?
like this my_matrix[6,19,23], but is it correct?
|
|
|
|
|
|
Sasuko wrote:
like this my_matrix[6,19,23], but is it correct?
No, you want to do this:
my_matrix[8,22,25]
Now you can access items starting at 1, and ending at 7/21/24 and just ignore the items that exist in the zero index of each array.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a try/catch block around my entire application ( in my static void main ) which catches all errors and writes them to a log file. Sometimes, this fails, and instead an ugly error/no log file is created. However, I've had some clients send me a log file that is obviously not generated by me, and it seems that some other program is catching my errors and logging them for them. Is there a reason my generic try/catch fails ? Can some other program supercede it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Can I ask you something that I asked my self many time?,What if an error has been found in the try block and then the control goes to the catch block and for the bad luck another error happened in the catch block (As the try/catch doesn't have a parent try block)?,and :
Christian Graus wrote:
and instead an ugly error/no log file is created
this may be because of this,accourding to no file creation permission.
And also what if this happened in the Finaly block itself ?(This is going to be executed whatever happened).
|
|
|
|
|
Yeah, I discovered this morning that my static file instance can be accessed in my single threaded application in such a way that it is still null, while it's been set to open the file already a moment before ( so I get a cannot open file exception ). I have to work out why this is, but in the meantime, I think a rethrow here has to be the problem. The thing is, no error log is being created at all for my client, and the exception they catch and report is not generated by code within my catch block.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is it giving him an exception or its somehing wrong in your code?
|
|
|
|
|
I'm not sure what you mean ? There's obviously an underlying bug that I need to fix, or there would be no exception. However, the other issue I'm trying to pursue is why the user doesn't get a polite error message and a log file to help me diagnose the problem, although some clients are providing a stack trace that obviously did not come from my log file and reporting a normal, ugly exception.
I think the issue I just found with the double initialised file object is the cause, although it's got me beat why that is happening.
public static void ForceLog(string Message)
{
if (debugFile == null)
{
debugFile = new StreamWriter(@"c:\RDC Error Log.txt", true, System.Text.Encoding.ASCII);
debugFile.WriteLine("Program started - " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
}
debugFile.WriteLine(Message);
debugFile.Flush();
}
This is supposed to initialise the log file on first write, and report that logging has started. Every other time, it should just log another message. Yes, the file gets closed when the program closes.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote:
I'm trying to pursue is why the user doesn't get a polite error message and a log file to help
What about replacing this method of the log by another that is displaying the error in a message boxes,at least you may know that the problem is in the creation of the log file or not.
Christian Graus wrote:
providing a stack trace that obviously did not come from my log
May you try to use it to know the error or what is going wrong in your app,before you try to get rid of it.
Christian Graus wrote:
debugFile == null
Try to use File.Exists(); for testing.
|
|
|
|
|
The config file allows the user to set if the error comes up in a message box, or goes to the log file, or both.
LongHC wrote:
May you try to use it to know the error or what is going wrong in your app,before you try to get rid of it.
I'm trying to get rid of the problem with the log file, I'm not trying to swallow an error without fixing it. As far as I am concerned, the fact that the log file is not generated is a seperate error, the one I am trying to fix. I think I have it, with what I discovered this morning. I've already fixed the error that was being reported, which is why I am focusing now on the error with my error logging.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I don't know if it's better, but take a look at the Application.ThreadException event. That's the one I use for catching and logging all unhandled exceptions and to give the user the option to restart the application.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Brilliant, thank you.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
BTW., I've seen a discussion on try/catch not catching exceptions occurring in a form, although the matching ShowDialog() was enclosed in a try/catch block.
This doesn't happen when you run the application from VS, but when your client executes the application without VS, the execeptions won't get caught
The solution is to add a ThreadException handler in the class showing the dialog and to re-throw the exception there.
Don't ask me why this has to be done exactly (someone from M$ tried explaining in a newsgroup), but it's working.
Regards,
mav
|
|
|
|
|
Maybe this is implied by your answer:
Is there a way to programatically shutdown and restart a .Net application? If so, how do you do it?
Gary Kirkham
Forever Forgiven and Alive in the Spirit
He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot
Me blog, You read
|
|
|
|
|
Gary Kirkham wrote: Is there a way to programatically shutdown and restart a .Net application? If so, how do you do it? Well, what you do is start another instance of the application before shutting down the current instance.
When I trap the exception, I display a dialog with all the exception details. When the form is closed, if a checkbox is checked, I start another instance of my own application, and then shut down the application. This is my handler for the Close button on the exception report form:
private void btnClose_Click(object sender, System.EventArgs e)
{
if(chkRestart.Checked)
System.Diagnostics.Process.Start(Application.ExecutablePath);
Application.Exit();
DialogResult = DialogResult.OK;
}
I hope this helps!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
It did help...thank you
Gary Kirkham
Forever Forgiven and Alive in the Spirit
He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot
Me blog, You read
-- modified at 14:07 Thursday 13th October, 2005
|
|
|
|
|
You're welcome! I'm glad I could help... on a four-months old thread
BTW, how did you end up here?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Luis Alonso Ramos wrote: BTW, how did you end up here?
message board search using the word "restart"
Gary Kirkham
Forever Forgiven and Alive in the Spirit
He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot
Me blog, You read
|
|
|
|
|
I am executing a program on the machine using the following code:
Process p = new Process();
p.StartInfo.FileName = "applicationname.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit();
p.Dispose();
If this program should crash for some reason (which it does at times), the OS will show the standard window that says the program has performed an illegal operation and must close. I realize that the real solution here would be to fix the bug in this third-party application, but in the mean-time I need to have my application give a friendly error message instead.
Is there anyway for my application to know when that application crashed and display appropriate instruction to the user rather than the OS giving the standard illegal operation message?
Any information would be greatly appreciated.
Thanks!
Daniel Smith
|
|
|
|
|
I need to have my application give a friendly error message
Inever saw a frendly error message
But you can catch te system message about the error a simply way:
<br />
<br />
Process p = new Process();<br />
<br />
try<br />
{<br />
p.StartInfo.FileName = "applicationname.exe";<br />
p.StartInfo.CreateNoWindow = true;<br />
p.StartInfo.UseShellExecute = false;<br />
p.Start();<br />
p.WaitForExit();<br />
p.Dispose();<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show("The frendly error message is:\n"+ex.Message);<br />
}<br />
Hope it's help
|
|
|
|
|
That would work if it were a .net exception being thrown. However, it is not. It is a third-party win32 application that is having an error that is causing the OS to close it.
I need to be able to hide the error displayed by the operating system and show a friendly error from in my application.
Thanks!
Dan
|
|
|
|
|
I have a client who writes software for the vet market. We're integrating his software ( x ray analysis ) with other vet software ( client billing ) and I import their COM objects in order to do this. Now, we've been using a pre release build for me to write this code, and they came out with the release build, and my code no longer works. I replaced the exe with the new version ( the GUIDs should not have changed ) and now the project complains that it cannot find the object to import it. In other words, I need to do a build for each version of the client COM object that exists.
There will be more versions in the future, how do I work my way around this ?
Christian Graus - Microsoft MVP - C++
|
|
|
|