|
Maple syrup and brown suger. Mmmmmm. Lovely.
Of course, as I'm trying to lose wait, I merely added raisins.
|
|
|
|
|
Pete O'Hanlon wrote: I'm trying to lose wait
That sounds impatient. Or did you mean "weight"?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
A bit of both. I'm impatient about losing weight.
|
|
|
|
|
Yeah, so am I, but, you have to "cheat" every now and then!
|
|
|
|
|
but, but, but..., the labels on the brown sugar and maple syrup each said that they had 0 g Fat per serving, so they can't make you gain weight, right?
It least that is what all those zero fat diet food ads imply.
|
|
|
|
|
I prefer oatmeal or oatbran with some candied pecans and fresh blueberries. I have eaten that every morning for the last several months.
|
|
|
|
|
And??
Oh well....thanks for telling us.....I guess.
When you learn to talk to humans, be sure to let us know!
|
|
|
|
|
Ok, here is my problem:- I have a tcp connection to an instrument; it is the slave and I am it's master (it speaks only when spoken to). Below is an example of how this conversation might look:-
Array.Clear(this.RXstring, 0, this.RXstring.Length);
sendMessage(buildMessage(Operation.Query));
System.Threading.Thread.Sleep(2000);
try
{
int len = this.tcp_com.Receive(this.RXstring);
string temp = ASCIIEncoding.ASCII.GetString(this.RXstring, 0, len);
if(temp.Contains("DYNAMIC")
{
this.dynamic = true;
}
else
{
this.dynamic = false;
}
}
Problem is this:- Sometimes, the data can be truncated or for some reason, maybe too big for the buffer and so a bit gets left behind. If I try and read without there being any data, it becomes stuck so I have made my buffer 1024 bytes long and added some time to try and make sure it's all arrived.
I would like to be able to clear the port somehow so that I know that there is only valid data when I get a responce and not something left over from last rx. Alternativey, I would like to be able to ask if there is data there without it crashing; I could then retrieve and discard myself.
I know that there are other ways I could have implemented the tcp bit but this seemed the simplest at the time.
As usual, all thoughts and advise gratefully received...
|
|
|
|
|
This is probably not how I would do it, but if things are as simple as you describe and you don't think it will change in the future, you should be able to make it work.
Your code is basically very similar to the sample code in this MSDN article: http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=vs.100).aspx[^].
Notice in SocketSendReceive() how they do the Receive() in a while loop, adding to the final string each time through the loop (if you follow that sample, you might want to use a StringBuilder object instead of just adding onto the string).
I suspect your truncated and left over data issues are due to the fact that you just try to read the data into your fixed size buffer in a single Receive() call. If you don't want to use a while loop in the reading part, you could use the socket objects Available property[^] to see how much data has been received and set the size of your buffer accordingly. It is not something I will recommend because you might have to change the sockets ReceiveBufferSize to be able to receive the largest data block the device can send to you - that can end up being a frustrating back and forth exercise.
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty
|
|
|
|
|
Thanks Soren, yes it is generally known what will be replied and that is all I will ever need to recieve. It was the "Available" that I wanted - I'm now able to read only when there is data as well as clear anything still there.
|
|
|
|
|
You can use the Available property[^] (and others) to check the status of the connection. You should also not assume that your Receive call will get all the data in one go; unless the device sends you an indicator with each message. You should continue to check until there is no more data on the connection.
Use the best guess
|
|
|
|
|
TCP sends messages. You get rid of the message by reading it. All of it.
It gets 'stuck' because it is doing a blocking read because there is nothing left to read.
The simple and correct solution is to read the entire message. If you cannot accurately determine the message size then you have a problem that is likely not solvable.
If the device itself is failing to send a complete message then you can use a timeout to attempt to read the complete message. However that doesn't help on the next message if the rest of the message came in later.
Why not just drop and recreate the connection each time?
|
|
|
|
|
after I run my windows application(c#) program and entering some digits and add to one list(showing one gif image to load) suddenly,after 5 or 6 times the shape of all buttons and labels Gradually change into cross shape.but also this happens in just some computers.thanks very much if you can help me.
|
|
|
|
|
No idea whatsoever. Sorry. As you haven't provided any code for us to look at, there's not a lot we can do.
Have you looked at the eventlog on the affected machines to see if there's anything being written there?
|
|
|
|
|
It might be worth just checking that it doesn't happen with any other application too.
|
|
|
|
|
Hi All,
string pattren = " INC | TRUST | COMPANY | 401K ";
string[] ArrPattern = pattren.Split('|');
above the string array i need to concatenate all the posibilities like below output,
ex:
INC PLAN COMPANY 401K
INC PLAN COMPANY empty
INC PLAN empty 401k
INC PLAN empty empty
INC empty COMPANY 401k
INC empty empty 401k
INC empty empty empty
empty PLAN COMPANY 401k
...
...
...
like these 16 combination....
please share your ideas its very urgent for me...
Regards,
Ram
|
|
|
|
|
sethupathiram wrote: please share your ideas its very urgent for me
So what have you got so far? What code have you written? Which part is causing you a problem?
|
|
|
|
|
|
|
Something like this should work:
static IEnumerable<T[]> BuildCombinations<T>(T[] input)
{
int length = input.Length;
int max = checked(1 << length);
for (int combination = 1; combination < max; combination++)
{
var current = new T[length];
for (int index = 0, bit = 1; index < length; index++, bit <<= 1)
{
if ((combination & bit) != 0)
{
current[index] = input[index];
}
}
yield return current;
}
}
...
string pattern = " INC | TRUST | COMPANY | 401K ";
string[] ArrPattern = pattern.Split('|');
List<string[]> allCombinations = BuildCombinations(ArrPattern);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I don't find any other better combinations for it, all the BEST possibilities are mentioned in your thread itself.
|
|
|
|
|
I am getting error
Error 1 The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?) on the subject while trying to build this with Visual C#:
using System;
using System.Windows.Forms;
using SKYPE4COMLib;
namespace SkypeBing
{
public partial class Form1 : Form
{
private Skype skype;
private const string trigger = "!";
private const string nick = "BOT";
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
skype = new Skype();
skype.Attach(7, false);
skype.MessageStatus +=
new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
}
private void skype_MessageStatus(ChatMessage msg,
TChatMessageStatus status)
{
string command = msg.Body.Remove(0, trigger.Length).ToLower();
skype.SendMessage(msg.Sender.Handle, nick +
" Says: " + ProcessCommand(command));
}
private string ProcessCommand(string str)
{
string result;
switch (str)
{
case "uli":
result = "http://www.youtube.com/watch?v=VfvBQMqCZw8";
break;
default:
result = "Uliuli";
break;
}
return result;
}
}
}
Whole error:
Error 1 The type or namespace name
That is the whole error.
Line 99 Column 33
modified 13-May-13 10:45am.
|
|
|
|
|
Which line does the error occur on?
Use the best guess
|
|
|
|
|
Error 1 The type or namespace name
That is the whole error.
Line 99 Column 33
|
|
|
|
|
Topias Jäppilä wrote: C:\Users\Topsu\Documents\Visual Studio 2012\Projects\Skaip\Skaip\Program.cs 19 I think you actually mean line 19. However, you also have not shown us the content of Program.cs so we cannot guess what is wrong in there.
Use the best guess
|
|
|
|