Serious Socket Programming Problems With System.Net.Sockets.NetworkStream

Serious Socket Programming Problems With System.Net.Sockets.NetworkStream

Post by A_StClaire » Mon, 25 Sep 2006 05:27:02


hello,

I just started working with this class at the low level and am having
issues.

1) I am instantiating a StreamReader and feeding my NetworkStream to
its constructor. the bytes that the StreamReader reads from the server
are perfect. however the StreamReader never stops reading / listening!
even after the last byte has been received! it just keeps blocking
and freezing my client app. does anyone know why this is and what can
be done about it?

2) as a workaround to 1), I am parsing the server response to find the
last byte. when I do I manually stop the StreamReader. is this really
a "workaround" or is it basically what the System.Web.HttpRequest
object does behind the scenes?

3) using the process described in 2) my client runs fine - but only in
debug mode. in release mode the server response is empty. this seems
to be due to bad code. I get my StreamReader to read the NetworkStream
object directly after my StreamWriter wrote a HTTP request to it. is
there a command I should call in between the two? you know, to delay
the read until a server response has been received?

long questions, I know.

thx for your time
 
 
 

Serious Socket Programming Problems With System.Net.Sockets.NetworkStream

Post by Arkady Fre » Mon, 25 Sep 2006 22:27:34

Look at example on
http://www.yqcomputer.com/
Arkady

 
 
 

Serious Socket Programming Problems With System.Net.Sockets.NetworkStream

Post by William St » Tue, 26 Sep 2006 09:09:50

Is this a simple 1 time request/reply? If so, on the client, read till
closed (i.e. null return, depending on what Read method your using). On the
server, close the send side after the reply. This way, you don't need to
count chars, just keep reading until EOS. Can we see some code?

--
William Stacey [MVP]



| hello,
|
| I just started working with this class at the low level and am having
| issues.
|
| 1) I am instantiating a StreamReader and feeding my NetworkStream to
| its constructor. the bytes that the StreamReader reads from the server
| are perfect. however the StreamReader never stops reading / listening!
| even after the last byte has been received! it just keeps blocking
| and freezing my client app. does anyone know why this is and what can
| be done about it?
|
| 2) as a workaround to 1), I am parsing the server response to find the
| last byte. when I do I manually stop the StreamReader. is this really
| a "workaround" or is it basically what the System.Web.HttpRequest
| object does behind the scenes?
|
| 3) using the process described in 2) my client runs fine - but only in
| debug mode. in release mode the server response is empty. this seems
| to be due to bad code. I get my StreamReader to read the NetworkStream
| object directly after my StreamWriter wrote a HTTP request to it. is
| there a command I should call in between the two? you know, to delay
| the read until a server response has been received?
|
| long questions, I know.
|
| thx for your time
|