473,414 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

streamreader hangs out

hi,

I have the following code. It hangs out and waits infinitely on
StreamReader.Read method.
any ideas?
thanks in advance...

WebRequest myHttpWebRequest = WebRequest.Create(myUri);

myResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

Stream ReceiveStream = myResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding(1254);

StreamReader sr = new StreamReader(ReceiveStream, encode);

Char[] read = new Char[1024];

int count = sr.Read(read, 0, 1024);

StringBuilder strHTML = new StringBuilder();

while (count > 0 && strHTML.Length <= MAX_SIZE)

{

String str = new String(read, 0, count);

strHTML.Append(str);

count = sr.Read(read, 0, 1024); ----> hangs out here....

}

sr.Close();


Nov 17 '05 #1
1 1740
Tunga Torgal wrote:
hi,

I have the following code. It hangs out and waits infinitely on
StreamReader.Read method. any ideas?
thanks in advance...

WebRequest myHttpWebRequest = WebRequest.Create(myUri);

myResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

Stream ReceiveStream = myResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding(1254);

StreamReader sr = new StreamReader(ReceiveStream, encode);

Char[] read = new Char[1024];

int count = sr.Read(read, 0, 1024);

StringBuilder strHTML = new StringBuilder();

while (count > 0 && strHTML.Length <= MAX_SIZE)

{

String str = new String(read, 0, count);

strHTML.Append(str);

count = sr.Read(read, 0, 1024); ----> hangs out here....

}

sr.Close();


Did you try to read the raw stream completely and decode the bytes
later?
Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Lou | last post by:
I am using the StreamReader to read data from a network pipe. these function hang sr.peek() sr.readAll() sr.read() when there is no more data in the pipe. sr.ReadLine works because there are...
3
by: redneon | last post by:
I have a program which is constantly reading from a stream and what I'm wanting to do is, if the stream hasn't sent anything after a certain amount of time then do something. I've tried doing this...
4
by: Astronomically Confused | last post by:
using System; using System.Collections; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; class HttpProcessor { private Socket s;
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
13
by: mloichate | last post by:
I must read a very heavy-weight text plain file (usually .txt extension) )and replace a given character with another given character in all text inside the file. My application was working pretty...
1
by: Rob T | last post by:
Hi, I have a simple little program that I'm going to use to access our SMTP server. The below code works perfectly fine, but my question is if I were to try to execute the last line...
11
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS 2005, ,.net 2 for C# windows application. I'm using Process to run a C application and redirecting its standard output so I can read it with StreamReader.ReadToEnd. It's only...
3
by: stumorgan | last post by:
I'm doing some USB communications in C# and am running into a minor annoyance. I'm using the Windows API CreateFile function to get a SafeFileHandle, which I then stuff into a FileStream and from...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.