473,789 Members | 2,388 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 1257
do not crosspost

there are answers on

microsoft.publi c.win32.program mer.networks

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

<mu***********@ gmail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.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.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 #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
2164
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...
0
1483
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" traget="_blank" href="view.aspx?id=3" traget="_blank" href="view.aspx?id=4" traget="_blank"
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
1128
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 Stream as network stream Public Sub Connect() Client.Connect(..)
5
24020
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
1184
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
9506
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
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10136
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
9016
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
7525
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
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2906
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.