[2.0] Infinite loop tcpclient
Code:
private void DoRead(IAsyncResult ar)
{
int BytesRead;
try
{
BytesRead = client.GetStream().EndRead(ar);
if ((BytesRead < 1))
{
Finished = true;
return;
}
strHTML += Encoding.ASCII.GetString(readBuffer, 0, (BytesRead - 2));
BytesRead = 0;
client.GetStream().BeginRead(readBuffer, 0, READ_BUFFER_SIZE, new System.AsyncCallback(this.DoRead), null);
}
catch (Exception)
{
// Future Handle
}
}
I call it like this:
Code:
client.GetStream().BeginRead(readBuffer, 0, READ_BUFFER_SIZE, new AsyncCallback(DoRead), null);
while (Finished != true)
{
Application.DoEvents();
}
Finished = false;
I fixed it i just needed to get rid of doevents.
Re: [2.0] Infinite loop tcpclient
Couldn't you use an HttpWebRequest?
Re: [2.0] Infinite loop tcpclient
I don't know if this might help, but it's because byteread is never less than 1. I got that problem once and when I changed it to bytesRead <1024, it worked and is still working today. Probaly it might help I dont know. - Jennifer