473,394 Members | 1,946 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,394 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 1236
do not crosspost

there are answers on

microsoft.public.win32.programmer.networks

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

<mu***********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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 #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...
0
by: Dimitrios Mpougas | last post by:
Hello, I have two asp.net pages. The first is a page (main.aspx) wich has four links on it. The href value of each link is: href="view.aspx?id=1" traget="_blank" href="view.aspx?id=2"...
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: Inspired | 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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...

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.