|
Ah, that is so simple and effective, thank you it works great.
amclint
There's no place like 127.0.0.1
|
|
|
|
|
I am trying to read a variable number of bytes from another .Net application but the messages are not always received correctly, sometimes I read the first half of the message and then the second half. Since the message sizes I am sending are constantly changing, I know I cannot hardcode the receive buffer. Right now that is how I have it and it works most of the time when my update rate is 1x/second but not at 10x/second. My data is a string with ids and data values (id:value|id:value|...) that I convert to bytes before sending (.GetBytes(dataString)).
I keep reading on forums that the standard way of remedying this situation is to append the number of bytes to the front of the message but I cannot find any examples of how to do that. Some of the channels have a more data than others (40KB vs 500 bytes) but the sending routine is the same so I need to make sure it will work across all channels.
Any help would be appreciated - I am really on a tight schedule
thanks in advance
|
|
|
|
|
captainmogo wrote: I keep reading on forums that the standard way of remedying this situation is to append the number of bytes to the front of the message
Standard? I don't know if I would agree with that. In any event you are talking about a protocol[^].
|
|
|
|
|
When i was sending / receiving stuff, i would send one message which contains the length of the peice of data, so the receiving end knows what to expect, and had the buffer at say 50KB. The sending end would send in 50Kb chunks until the end of the file, and the receiving end would receive until it had the full 50KB chunk (not all the data comes through in one big chunk) or until it reached the end of the file.
It basically worked like this:
Sender: 123456 <- the size in bytes
Receiver: "OK";
Sender: *sends 50KB*
Receiver: *keeps trying to receive until 50KB has been downloaded*
Receiver: "OK";
Sender: *sends next 50KB*
Receiver: *keeps trying to receive until 50KB has been downloaded*
Receiver: "OK";
Sender: *sends last part of data (less than 50KB)*
Receiver: *keeps trying to receive until the current amount of bytes == total amount of bytes*
Receiver: "OK";
All done. I also had it send an MD5 hash, just to make sure nothing went wrong somewhere.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
If the buffer size is not hard coded, the process will have to retrieve one byte at a time from the socket and constantly resize the incoming buffer to accommodate the byte until the message has been received. That can be very time expensive.
What can be done is on the receive side, set up a hard coded buffer size. Each time a message is received, pass that buffer up to another method that will parse the buffer copying it into a second buffer. Then the original buffer is cleared. When the next message is received, the same process happens again. Let the parsing method determine when the message is complete and further processing of the completed message is necessary. This requires some analysis of the message and how it is structured so that the receiving process can put the message back together correctly.
There are many applications out there that do the second method effectively. In fact there are some examples on this web site of both methods.
Phil
|
|
|
|
|
I have been mia for the past few weeks but I am finally getting back to it. I understand the concept of your post but I am not really sure how to start implementing that. Would there be some sort of EOF char to determine the end of the message and then only pull out of the buffer up to that point. Would it be possible to maybe get me started on that. Thanks a lot
|
|
|
|
|
I'm beginner, with C#. I've learned basic language C# and Window forms.
Now, I want to build a application what allow create tasks list, appointments, to do list, calender...a desktop application run in system tray, show message at time that defined before...!
I used notify icon, contextmenustrip to minimize program into system tray...but I don't know how to continue develop program?
Somebody show me the way to go on, learn, reference articles or any books for my issues.
Thanks so much!
|
|
|
|
|
hanght wrote: I'm beginner, with C#. I've learned basic language C# and Window forms.
I think you should start a little smaller first.
only two letters away from being an asset
|
|
|
|
|
thanks for your idea! If you can, please give me a smaller project(I'll try it!)
I learned C,C++,VB(not API Programming)! I think I should learn more about system programming(as my project)(I've done a management application).
I hope will receive many your ideas...
|
|
|
|
|
Replacing windows calculator ( just the basic view ) is a good first C# project.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi, Before strat to doing a small project please try to learn ADO.NET concept (if u dont have) , coz, for any project you have to use database.... and the application you want to build will need database to maintain records....
Good luck !!!
Happy Programming
-----
Abhijit
|
|
|
|
|
hi there,
i m trying to set background image of picture box by texture that will be filled by textureloader
but i have a problem that when i m trying to load texture its giving error
that is "Error in application"
codes :
private Texture texture;
private Device gDevice;
...........................
...........................
texture = TextureLoader.FromFile(gDevice, @"C:\asasa.ddt", 256, 256, 0, Usage.Dynamic, Format.Dxt3, Pool.Default, Filter.None, Filter.None, 0);
any idea to solve the problem?
Becoming Programmer...
|
|
|
|
|
It might be helpful to include the error you are getting
only two letters away from being an asset
|
|
|
|
|
"Direct3DXException was unhandled"
Becoming Programmer...
|
|
|
|
|
xmen_xwk wrote: "Direct3DXException was unhandled"
So you're doing Direct3D development but you don't know that you should be posting the contents of the exception in order to receive help. I think you are missing some fundamental aspects of software development while proceeding to a somewhat advanced topic.
|
|
|
|
|
|
|
hahaha, i just wrote what i m getting by VC#
Becoming Programmer...
|
|
|
|
|
Have you tried the view details link on the exception dialog? That should give you more details, including a stack trace that help to narrow your problem.
only two letters away from being an asset
|
|
|
|
|
|
Can i use Lambda Expressions in C# 2.0?
|
|
|
|
|
No. C# 2 doesn't provide lambda expressions, C# 3 does however. You can use a more verbose form of a lambda, an anonymous method, in C# 2.
public void DoSomething()
{
int someLocal = 7;
MethodInvoker anonymousMethod = delegate
{
MessageBox.Show(someLocal.ToString());
};
}
|
|
|
|
|
Hi,
I have come across a big problem.I have developed my application in C# just a few days before and today when I when searching the internet I found some software like ".NET Decompiler" . I wondered that how is it possible ? Then when I downloaded it any opened my executable it it, With my wonder the whole exe was converted to a full formated source code !! I was just too much shocked seeing all this ! What's it ? Any problem in .NET Complier method or what ? How can an exe be converted to source code ? Anyone PLEASE HELP...
Thanks,
Dan.
|
|
|
|
|
|
That's how it is in the .Net world.
It gives advantages like the cool features available in reflection but unfortunately it exposes the inner workings of your code to the outside world. You could try using an obfuscater to make your source less readable.
Russ
|
|
|
|