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

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.GetStream()
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 "ClientClass", 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.Connect()
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.Connect()"
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.Connect() 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 1114
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...however u chose to do it, then once socket is
connnected do this

ClientStream = new NetworkStream(ClientSocket)

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
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...
0
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...
0
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 =...
3
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...
5
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...
3
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...
1
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...
5
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...
2
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.