473,804 Members | 3,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1597
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.Sock ets 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******@thisp artgoesaways.st art.no> wrote in message
news:OP******** ******@TK2MSFTN GP09.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******@thisp artgoesaways.st art.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.Strea m.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.N ull
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******@thisp artgoesaways.st art.no> wrote in message
news:OU******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP11.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.Sock ets 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
556
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. I am sending a small amound of data and read where data wasn't sent until the buffer reached a larger size. However, there is a TcpClient property call NoDelay that is suppose to eliminate this delay. Here is a snippet of my code below. Can...
1
1819
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 open neworkstream and streamwriter, send data and then close it syncrhronously or do i have to implement some callbacks/events to do this like in vb6? TcpClient myclient;
4
7209
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 one of these things and it WON'T read data. If I set a breakpoint in my EndRead callback, it never goes off. NOTHING is different from anywhere else I use this class, its just this one place. Now, if I create a second constructor for my class...
1
2655
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 "unable to write data to transport connection" error. I have tried multiple ways to transfer this file(including remoting, sockets without network stream) and downloaded different examples of client/server byte transfer, all with the same result....
6
3329
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 data. The
1
3360
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 that i can communicate with the servet just for one time,the first time i connect to the server,send data and receive response,but when i want to receive data for another time,there won't be any response.some body help me please,whats the problem???...
0
1346
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 tcpServer = new TcpListener(localAddr,port);
2
4104
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 = tcpListenerServer.AcceptTcpClient();
7
4277
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 results to clients. The code below makes the client application not to respond. Client can send data but is stuck in the process of waiting information back from the server. Any ideas?
0
9575
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10308
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6846
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2981
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.