URGENT!! NetworkStream "null reference" problem.

M

mulham.haffar

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.
 
V

Vadym Stetsyak

do not crosspost

there are answers on

microsoft.public.win32.programmer.networks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top