Click here to Skip to main content
15,897,273 members
Home / Discussions / C#
   

C#

 
QuestionA new line in textbox control Pin
Ahmed Ismail Mohamed3-Sep-06 2:57
Ahmed Ismail Mohamed3-Sep-06 2:57 
AnswerRe: A new line in textbox control Pin
Stefan Troschuetz3-Sep-06 3:24
Stefan Troschuetz3-Sep-06 3:24 
AnswerRe: A new line in textbox control Pin
Syed Shahid Hussain3-Sep-06 6:05
Syed Shahid Hussain3-Sep-06 6:05 
AnswerRe: A new line in textbox control Pin
Michael P Butler3-Sep-06 9:45
Michael P Butler3-Sep-06 9:45 
QuestionSaving Image file in database ... Pin
mrkeivan3-Sep-06 2:39
mrkeivan3-Sep-06 2:39 
AnswerRe: Saving Image file in database ... Pin
Michael P Butler3-Sep-06 9:47
Michael P Butler3-Sep-06 9:47 
AnswerRe: broken article, please help:( Pin
Michael P Butler3-Sep-06 9:48
Michael P Butler3-Sep-06 9:48 
GeneralRe: broken article, please help:( Pin
Muammar©6-Nov-06 0:00
Muammar©6-Nov-06 0:00 
QuestionFile System (about stream reader) Pin
Syed Shahid Hussain2-Sep-06 22:30
Syed Shahid Hussain2-Sep-06 22:30 
AnswerRe: File System (about stream reader) Pin
Nader Elshehabi2-Sep-06 22:46
Nader Elshehabi2-Sep-06 22:46 
GeneralRe: File System (about stream reader) Pin
Syed Shahid Hussain3-Sep-06 5:41
Syed Shahid Hussain3-Sep-06 5:41 
AnswerRe: File System (about stream reader) Pin
Nader Elshehabi3-Sep-06 12:03
Nader Elshehabi3-Sep-06 12:03 
GeneralRe: File System (about stream reader) Pin
Syed Shahid Hussain4-Sep-06 6:30
Syed Shahid Hussain4-Sep-06 6:30 
AnswerRe: File System (about stream reader) Pin
John Petersen3-Sep-06 0:07
John Petersen3-Sep-06 0:07 
GeneralRe: File System (about stream reader) Pin
Syed Shahid Hussain3-Sep-06 5:45
Syed Shahid Hussain3-Sep-06 5:45 
Questionquestions about Setup & Deployment ? help please ... Pin
cmpeng342-Sep-06 16:17
cmpeng342-Sep-06 16:17 
AnswerRe: questions about Setup & Deployment ? help please ... Pin
Nader Elshehabi2-Sep-06 19:33
Nader Elshehabi2-Sep-06 19:33 
AnswerRe: questions about Setup & Deployment ? help please ... Pin
mav.northwind2-Sep-06 19:53
mav.northwind2-Sep-06 19:53 
QuestionNewbie: The best way to detect the end of a data stream... Pin
Phillip Hodges2-Sep-06 13:44
Phillip Hodges2-Sep-06 13:44 
Hello all.. I am trying to construct a way of extracting data from a network stream.

However I am running into a small problem. I am using regex to detect a pair of return & newlines "\r\n\r\n". However some of the messages received have "\r\n\r\n" in the middle of the stream. So some of the messages are cut off halfway.

<br />
                byte[] ami_response_buffer = new byte[ami_buffer_size];<br />
                MemoryStream ami_memory_stream = new MemoryStream();<br />
                string ami_response = "";<br />
                int ami_bytes_read = 0;<br />
<br />
                do<br />
                {<br />
                    ami_bytes_read = ami_client_stream.Read(ami_response_buffer, 0, ami_buffer_size);<br />
                    ami_memory_stream.Write(ami_response_buffer, 0, ami_bytes_read);<br />
                    ami_response = Encoding.ASCII.GetString(ami_memory_stream.GetBuffer());<br />
<br />
                    // Check for end of message<br />
                    if (Regex.Match(ami_response, "\r\n\r\n", RegexOptions.IgnoreCase).Success)<br />
                    {<br />
                        ami_bytes_read = 0;<br />
                    }<br />
                }<br />
                while (ami_bytes_read > 0);<br />
                <br />
                return ami_response;<br />


What is the best way to detect the end of a data stream?

Thanks in advance...


Phil



"Rules are for the obedience of fools and the guidance of wise men"

AnswerRe: Newbie: The best way to detect the end of a data stream... Pin
Nader Elshehabi2-Sep-06 14:17
Nader Elshehabi2-Sep-06 14:17 
AnswerRe: Newbie: The best way to detect the end of a data stream... Pin
Scott Dorman2-Sep-06 14:52
professionalScott Dorman2-Sep-06 14:52 
QuestionWindow is minimized after showing Splash Screen. Pin
Nadia Monalisa2-Sep-06 9:37
Nadia Monalisa2-Sep-06 9:37 
AnswerRe: Window is minimized after showing Splash Screen. Pin
Nader Elshehabi2-Sep-06 12:13
Nader Elshehabi2-Sep-06 12:13 
GeneralRe: Window is minimized after showing Splash Screen. Pin
mav.northwind2-Sep-06 19:57
mav.northwind2-Sep-06 19:57 
JokeRe: Window is minimized after showing Splash Screen. Pin
Nader Elshehabi2-Sep-06 21:38
Nader Elshehabi2-Sep-06 21:38 

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.