By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,375 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

DataAvailable should throw an exception...

P: n/a
Hi
I'm using a TCPClient to connect to a remote server, and I get messages from
this server using the associated NetworkStream.
As soon as I'm connected to the server, I use this code to read data :
while (stream.DataAvailable)
{
// there is data, read them
int numberOfBytesRead = stream.Read(m_readBuffer, m_currentIndex,
m_readBuffer.Length - m_currentIndex);
.....
}
If I look the documentation for 'DataAvailable', it says : " If the remote
host shuts down or closes the connection, DataAvailable throws a
SocketException "
My problem is that I never get this exception thrown. I close the remote
server, and my client keeps telling me there are no data available... and
doe snot throw...
Do you know what's wrong ?
thanks
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
There definitely is a problem with DataAvailable, I'm not the only one to
report this.
http://www.error-bank.com/microsoft....39_Thread.aspx

It seems to be a bug.

"palaga" <fb*********@ubisoft.fr> a écrit dans le message de
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi
I'm using a TCPClient to connect to a remote server, and I get messages from this server using the associated NetworkStream.
As soon as I'm connected to the server, I use this code to read data :
while (stream.DataAvailable)
{
// there is data, read them
int numberOfBytesRead = stream.Read(m_readBuffer, m_currentIndex,
m_readBuffer.Length - m_currentIndex);
....
}
If I look the documentation for 'DataAvailable', it says : " If the remote
host shuts down or closes the connection, DataAvailable throws a
SocketException "
My problem is that I never get this exception thrown. I close the remote
server, and my client keeps telling me there are no data available... and
doe snot throw...
Do you know what's wrong ?
thanks

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.