473,379 Members | 1,379 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,379 software developers and data experts.

NetworkStream

Hi!

How do i check: if "NetworkStream.Null = true then" it says .Null does not
supports type Boolean

Thanks
/Kai
Nov 20 '05 #1
4 1581
Kai,
Can you provide significantly more information as to what the problem is. As
what you have doesn't have ANY context with it, so we don't really know what
you are talking about or referring to.

Providing about 5 to 10 lines of code on what you are doing would be
helpful, especially if those 5 to 10 lines compile (by themselves) with the
error you are seeing! Then we at least have a context on what is going
wrong.

BTW: NetworkStream is a class in the System.Net.Sockets namespace, however
it does not have a Null property, so obviously you cannot check to see if
"null" is true or not?

Hope this helps
Jay

"Kai Thorsrud" <ka******@thispartgoesaways.start.no> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Hi!

How do i check: if "NetworkStream.Null = true then" it says .Null does not supports type Boolean

Thanks
/Kai

Nov 20 '05 #2
"Kai Thorsrud" <ka******@thispartgoesaways.start.no> schrieb

i'm passing Network streams between classes and i want to check if
the stream still is open. According to my MSDN help you are correct
that there are no Null property but according to .Net it seems so and
it seems to fulfill what i want to check. it must be something wrong
with my .Net install then or is it some class inherentace from
objects in general ?

However canread fails if the stream is not open so where do i put my
check ?
Does the DataAvailable property help?
look at attached picture


Null is a shared member. It is actually System.IO.Stream.Null and points to
a "Null"-Stream. See docs on Null member.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
Kai,
but according to .Net it seems so and it seems to
fulfill what i want to check. O.K. I see what you are seeing. You are seeing Stream.Null which is a "Null
Object". "Null Object" is a specific application of the Special Case
Pattern. http://www.martinfowler.com/eaaCatalog/specialCase.html

Null objects are useful in routines where you do not want to be constantly
checking to see if an object reference is Nothing (Null) or not. They are
not used to see if a Stream is open or not per se.

To check to see if you were passed Stream.Null or not you would use the Is
operator. However generally you should be writing your routines in such a
manner that it doesn't matter if you were passed a real Stream or
NetworkStream object, or the Stream.Null object.

Dim myStream As NetworkStream

If myStream Is Stream.Null Then

End If

Because NetworkStream inherits from Steam, you can use NetworkStream.Null
instead.
i'm passing Network streams between classes and i want to check if the
stream still is open. I do not know how to verify if the stream itself is open or not. Its not
Stream.Null as Stream.Null is a shared field (not an instance property).

Hope this helps
Jay

"Kai Thorsrud" <ka******@thispartgoesaways.start.no> wrote in message
news:OU**************@tk2msftngp13.phx.gbl... Hi!

i'm passing Network streams between classes and i want to check if the
stream still is open. According to my MSDN help you are correct that there
are no Null property but according to .Net it seems so and it seems to
fulfill what i want to check. it must be something wrong with my .Net
install then or is it some class inherentace from objects in general ?

However canread fails if the stream is not open so where do i put my check ?
look at attached picture

Thanks a lot Jay

B Regards
Kai

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eC**************@TK2MSFTNGP11.phx.gbl...
Kai,
Can you provide significantly more information as to what the problem is.
As
what you have doesn't have ANY context with it, so we don't really know

what
you are talking about or referring to.

Providing about 5 to 10 lines of code on what you are doing would be
helpful, especially if those 5 to 10 lines compile (by themselves) with

the
error you are seeing! Then we at least have a context on what is going
wrong.

BTW: NetworkStream is a class in the System.Net.Sockets namespace,

however it does not have a Null property, so obviously you cannot check to see if "null" is true or not?

Hope this helps
Jay


Nov 20 '05 #4
Thanks Jay :)

That solved the problem indeed..

Thanks for the splendid help.

/Kai
Nov 20 '05 #5

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

Similar topics

1
by: cmjman | last post by:
I have an issue where networkStream.Write doesn't perform its write downstream from my client program until the network stream is closed. I then see the data that was sent appear on the other side....
1
by: Daniel | last post by:
i would like to konw when the data sent so that i can close the streamwriter and networkstream is there some sort of call backs/events i have to implement for this to work? if so how? can i just...
4
by: 0to60 | last post by:
I have a class that wraps a TcpClient object and manages all the async reading of the socket. It works really nice, and I use it all over the place. But there's this ONE INSTANCE where I create...
1
by: kmacintyre | last post by:
I am trying to us a simple NetworkStream to transfer a file over tcp. This works most of the time, but one specific file never downloads(.mdb file). It seems to close the socket and I get an...
6
by: Ryan | last post by:
Hi, I am confused with how NetworkStream works. My application needs to handle heavy requests sent through TCP socket connection. I use NetworkStream.Read method to get the stream...
1
by: hamid_2020 | last post by:
I wrote a class to connect to a server using tcpclient. I need to connect to the server and the connection must be open.Then i need to send request to the server again and again.But the problem is...
0
by: Al Wilkerson | last post by:
Hey, Has anyone ever got a "Unable to read data from transport connected" message after reading data from a streamreader composed of a networkstream. For example: Server TcpListener...
2
by: PiotrKolodziej | last post by:
Hi I have a simple question. Here is the code related to my question: while (true) { if (tcpListenerServer.Pending() && !this.Disposing) { TcpClient tcpClient =...
7
by: littleIO | last post by:
Hi, I'm stuck on a very simple problem and just cant seem to get around it, little help would be much appreciated. I have a server which listens, receives calls, processes them and sends back the...
1
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: 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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.