473,320 Members | 2,162 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,320 software developers and data experts.

DataAvailable should throw an exception...

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
1 1210
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kerri | last post by:
Hi, I am new to .NET In my Error Logic on my Aspx pages when an error happens it hits my catch statement where I throw an Exception. My question is : what is the difference between Thwo...
4
by: Eric Lilja | last post by:
Hello, in my program I have a function (pseudo code): void start_mysql_service() { obtain handle start mysql service using handle if start fails close handle and throw an exception...
3
by: Pierre Rouleau | last post by:
The std::exception class defined in the Standard C++ <exception> header specifies that the constructors could throw any exception becuase they do not have a throw() specification. Why is that? ...
1
by: Hai Ly Hoang - MT00KSTN | last post by:
Hi, When NetworkStream.DataAvailable flag is toogled ? The explanation of MSDN is so vague and confusing ! Thanks
17
by: hplloyd | last post by:
Hi, I have a function that adds data to a database and I want to return true if the database was updated and false if there was a problem, so I am using a try... catch block... My problem is...
6
by: Arjen | last post by:
Hi, I'm reading the enterprise library documentation and there I see the throw statement. try { // run code } catch(Exception ex) {
6
by: Henryk | last post by:
I did a lot of delphi GUI programming recently. In my experience most of the time you just want to throw a standard exception with a descriptive message. Then all calling functions can handle...
28
by: Jess | last post by:
Hello, It is said that if I implement a "swap" member function, then it should never throw any exception. However, if I implement "swap" non- member function, then the restriction doesn't...
6
by: jason.cipriani | last post by:
Consider this program, which defines a template class who's template parameter is the type of an exception that can be thrown by members of the class: === BEGIN EXAMPLE === #include...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.