Click here to Skip to main content
15,922,155 members
Home / Discussions / C#
   

C#

 
GeneralRe: SENDING MAIL DID NOT USING GMAIL DOMAIN Pin
Pete O'Hanlon14-May-13 20:52
mvePete O'Hanlon14-May-13 20:52 
GeneralRe: SENDING MAIL DID NOT USING GMAIL DOMAIN Pin
N8tiv14-May-13 20:53
N8tiv14-May-13 20:53 
AnswerRe: SENDING MAIL DID NOT USING GMAIL DOMAIN Pin
N8tiv14-May-13 20:55
N8tiv14-May-13 20:55 
GeneralRe: SENDING MAIL DID NOT USING GMAIL DOMAIN Pin
mohamed kalif raja17-Jun-13 22:12
mohamed kalif raja17-Jun-13 22:12 
QuestionMessage Closed Pin
14-May-13 0:36
JAYRAJ GIRI14-May-13 0:36 
AnswerRe: Entity Frame work Pin
OriginalGriff14-May-13 0:41
mveOriginalGriff14-May-13 0:41 
AnswerRe: Entity Frame work Pin
Pete O'Hanlon14-May-13 2:10
mvePete O'Hanlon14-May-13 2:10 
GeneralRe: Entity Frame work Pin
Dave Kreskowiak14-May-13 3:50
mveDave Kreskowiak14-May-13 3:50 
GeneralRe: Entity Frame work Pin
Pete O'Hanlon14-May-13 3:53
mvePete O'Hanlon14-May-13 3:53 
JokeRe: Entity Frame work Pin
Richard Deeming14-May-13 3:59
mveRichard Deeming14-May-13 3:59 
GeneralRe: Entity Frame work Pin
Pete O'Hanlon14-May-13 4:01
mvePete O'Hanlon14-May-13 4:01 
GeneralRe: Entity Frame work Pin
Dave Kreskowiak14-May-13 3:59
mveDave Kreskowiak14-May-13 3:59 
GeneralRe: Entity Frame work Pin
TnTinMn14-May-13 11:12
TnTinMn14-May-13 11:12 
GeneralRe: Entity Frame work Pin
AspDotNetDev14-May-13 11:16
protectorAspDotNetDev14-May-13 11:16 
AnswerRe: Entity Frame work Pin
Dave Kreskowiak14-May-13 3:46
mveDave Kreskowiak14-May-13 3:46 
QuestionHow would you clear a tcp buffer or detect if there is data there ? Pin
Member 986287213-May-13 21:40
Member 986287213-May-13 21:40 
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:-
C#
//Clear RXstring.
Array.Clear(this.RXstring, 0, this.RXstring.Length);
//Build and send message.
sendMessage(buildMessage(Operation.Query));
//Couple of seconds delay is required before checking the data.
System.Threading.Thread.Sleep(2000);
try
{
  //Receive response from the Chamber Controller
  int len = this.tcp_com.Receive(this.RXstring);
  //Convert received ASCII bytes to string
  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...
AnswerRe: How would you clear a tcp buffer or detect if there is data there ? Pin
SoMad13-May-13 22:43
professionalSoMad13-May-13 22:43 
GeneralRe: How would you clear a tcp buffer or detect if there is data there ? Pin
Member 986287215-May-13 4:30
Member 986287215-May-13 4:30 
AnswerRe: How would you clear a tcp buffer or detect if there is data there ? Pin
Richard MacCutchan13-May-13 22:45
mveRichard MacCutchan13-May-13 22:45 
AnswerRe: How would you clear a tcp buffer or detect if there is data there ? Pin
jschell14-May-13 9:28
jschell14-May-13 9:28 
Questionruntime error Pin
n.nili13-May-13 19:04
n.nili13-May-13 19:04 
AnswerRe: runtime error Pin
Pete O'Hanlon13-May-13 21:22
mvePete O'Hanlon13-May-13 21:22 
AnswerRe: runtime error Pin
dusty_dex13-May-13 22:20
dusty_dex13-May-13 22:20 
Questionstring concatenation with all possibilities Pin
sethupathiram13-May-13 3:19
sethupathiram13-May-13 3:19 
AnswerRe: string concatenation with all possibilities Pin
Pete O'Hanlon13-May-13 3:30
mvePete O'Hanlon13-May-13 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.