473,802 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

URGENT!! NetworkStream "null reference" problem.

Hi, im writing an application that uses tcpclient to connect.

I have a class which makes the whole network stuff.. As below:

Public Class Connections
Private Client as tcpclient
Private Stream as network stream

Public Sub Connect()
Client.Connect( ..)
Stream = Client.GetStrea m()
End Sub
Public Function Send( str as string ) someStr as string
.... Some encoding then ..
Stream.Write(.. .)
..
..
End Function
End Class

I uses this class from another class called "ClientClas s", in this
class I have functions each one should send data using the previous
class's functions.

Public Class ClientClass
Private ConnecObj as new Connections

Private Function Login()
ConnecObj.Conne ct()
ConnecObj.Send( ...)
..
..
End Function

Private Function GetUsers()
ConnecObj.Send( ...)
End Function
End Class

In each of these functions i uses the "ConnecObj.Send (..)" directly
,except the first function "Login" i call the "ConnecObj.Conn ect()"
first to let the Stream has a reference.

THE PROBLEM is:
Every function except the login raises an exception telling that the
stream has a null reference.
I can fix it by calling ConnecObj.Conne ct() before each
ConnecObj.Send( ) but im opening a thread for client ( request ) , by
this way I hv to open a thread for send of each client.
Any idea is appreciated
Thanx in advance.

Dec 8 '05 #1
1 1130
hi, im by no means an expert on this but from when ive used network streams,
it looks like ur declaration might b wrong? but thats just a thought,
whenever ive used them, i always do this:

''Global Var Socket and stream
Private ClientSocket As Socket
Private ClientStream As NetworkStream

''Code to connect socket...howeve r u chose to do it, then once socket is
connnected do this

ClientStream = new NetworkStream(C lientSocket)

thats walways worked for me without fail...so i hope that helps

--
-iwdu15
Dec 8 '05 #2

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

Similar topics

2
5010
by: Ramki | last post by:
Hi, I want to call a PERL program from MS-DOS batch file. Following is just an example, the string may inturn have double quote or single quote. I can't call with arg1, arg2 etc, as the input will be dyanamic. My argument may be something like this "204.120.69.195" "-""-" 'xyz' "GET" Perl should receive the whole string as a single argument. I know it
0
1563
by: dicky2283 | last post by:
windows development community please help me im deepak roy , doing my final year undergrad in computer science.... im doing a project - Motion detection and Tracking in vc++( video for windows). The project combines image acquisition, manipulation techniques with other image processing techniques and neural network approaches. im using video for windows to capture images from a webcam( EZONICS CAM II ). if u have used video for windows,...
0
874
by: gops | last post by:
This is my sql query "SELECT UC_Course_Unit.Unit_ID, Unit.Unit_Name, UC_Course_Unit.Semester_Offered, UC_Course_Unit.Year_Offered FROM Unit INNER JOIN UC_Course_Unit ON Unit.Unit_ID = UC_Course_Unit.Unit_ID WHERE (((UC_Course_Unit.Unit_ID) Not In (SELECT OS_Course_Unit.Unit_ID FROM OS_Course_Unit WHERE (((OS_Course_Unit.OS_course_ID)="+ OscourseID +")))) AND ((UC_Course_Unit.Course_ID)='"+ UCCouseID +"'))ORDER BY...
3
2165
by: Microsoft Newsgroups | last post by:
Hi all, I'm having an interesting problem with my IE Webcontrols. I'm using the toolbar and when I test it in my browser using "http://localhost/mysite", it works fine. Incidentally, I have "mysite" set up as a web application. Now when I test it going through "http://mysite/no-ip.org" then the toolbar doesn't work properly. It seems to merely render the images and any subsequent embedded Javascript but there are no events fired to the...
5
1110
by: John F | last post by:
Hi all, I posted a question earlier but have since discovered something else. If anyone read my previous post, ignore the issue surrounding two different url's to one box since I've managed to re-create the problem another way. Simply put, my IE webcontrols are not working when I access my machine through the browser like "http://mymachinename/mysite/mypage.aspx" but the IE webcontrols DO work when I access my machine through my...
3
1463
by: Danny Tuppeny | last post by:
Hi all, This is quite urgent - I'll keep it brief... I've posted the WSDL, Proxy class etc. here: http://dantup.me.uk/SoapProb/ My problem is that the Soap Envelope looks fine, yet the .message property of the return object is null, and not the string in the envelope.
1
1258
by: mulham.haffar | last post by:
Hi, im writing an application that uses tcpclient to connect. I have a class which makes the whole network stuff.. As below: Public Class Connections Private Client as tcpclient Private Stream as network stream Public Sub Connect() Client.Connect(..)
5
24025
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP
2
1185
by: Saso Zagoranski | last post by:
Hi group, This probably isn't the right newsgroup to post this but I'm in a real hurry... (please direct me to the correct newsgroup if I'm "miss-posting") Could you please look at the following website: http://www.spletna-galerija.net/Gallery.aspx and tell me why the overflow in IE 6? It works fine in Firefox and IE7 ...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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
10304
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...
0
9114
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...
0
6838
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();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
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
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
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.