Click here to Skip to main content
15,887,676 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: Window is minimized after showing Splash Screen. Pin
mav.northwind2-Sep-06 20:12
mav.northwind2-Sep-06 20:12 
GeneralRe: Window is minimized after showing Splash Screen. Pin
Nadia Monalisa3-Sep-06 6:02
Nadia Monalisa3-Sep-06 6:02 
GeneralRe: Window is minimized after showing Splash Screen. Pin
mav.northwind3-Sep-06 8:49
mav.northwind3-Sep-06 8:49 
QuestionDo I need to Lock App.CONFIG for Multithreaded Access ? Pin
Nadia Monalisa2-Sep-06 8:23
Nadia Monalisa2-Sep-06 8:23 
AnswerRe: Do I need to Lock App.CONFIG for Multithreaded Access ? Pin
Mike Dimmick2-Sep-06 9:16
Mike Dimmick2-Sep-06 9:16 
GeneralRe: Do I need to Lock App.CONFIG for Multithreaded Access ? Pin
Nadia Monalisa2-Sep-06 9:30
Nadia Monalisa2-Sep-06 9:30 
GeneralRe: Do I need to Lock App.CONFIG for Multithreaded Access ? Pin
Judah Gabriel Himango2-Sep-06 11:18
sponsorJudah Gabriel Himango2-Sep-06 11:18 
Questiondynamically invoking a method in an assemly Pin
Sonu.T2-Sep-06 8:09
Sonu.T2-Sep-06 8:09 
AnswerRe: dynamically invoking a method in an assemly Pin
Stefan Troschuetz2-Sep-06 22:27
Stefan Troschuetz2-Sep-06 22:27 
GeneralRe: dynamically invoking a method in an assemly Pin
Sonu.T3-Sep-06 6:58
Sonu.T3-Sep-06 6:58 
QuestionOpening file Pin
thepersonof2-Sep-06 4:09
thepersonof2-Sep-06 4:09 

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.