473,400 Members | 2,163 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,400 software developers and data experts.

VBE 2005 NetworkStream Question

Dim clt as TcpClient
Dim stm as NetworkStream

clt = New TcpClient()
clt.Connect("192.168.0.200", 9999)
Do Until clt.Connected
Loop
stm = clt.GetStream
' --The following line throws "Object reference not set to an instance of an
object."
stm.BeginRead(buf, 0, 4096, AddressOf ReadEvent, Nothing
' --This also throws the same exception
stm.Close

I can find nothing in the documentation that says this is wrong.

Help? Thanks.
Nov 21 '05 #1
3 1292
What version of framework are you using? I don't see a "connected"
property for the tcpclient object in 1.1.

Regardless, I see that you have a Do..Loop there to make sure that the
client obejct can connect, but put a breakpoint on the
stm=clt.getstream line and then check the state of clt.connected again.
If it is closed, the GetStream method returns a ObjectDisposed
Exception, and so it is unable to "stm" to referense anything.

Nov 21 '05 #2
apologies, as soon as I clicked on the submit button, I noticed you had
VBE 2005 in your subject (VBSEG), so that answers which framework you
used. :)

Nov 21 '05 #3
I found the problem.

This...
stm.BeginRead(buf, 0, 4096, AddressOf ReadEvent, Nothing)
Should be...
stm.BeginRead(buf, 0, 4096, AddressOf ReadEvent, buf)

"Terry Olsen" <to******@hotmail.com> wrote in message
news:u6*************@tk2msftngp13.phx.gbl...
Dim clt as TcpClient
Dim stm as NetworkStream

clt = New TcpClient()
clt.Connect("192.168.0.200", 9999)
Do Until clt.Connected
Loop
stm = clt.GetStream
' --The following line throws "Object reference not set to an instance of
an object."
stm.BeginRead(buf, 0, 4096, AddressOf ReadEvent, Nothing
' --This also throws the same exception
stm.Close

I can find nothing in the documentation that says this is wrong.

Help? Thanks.

Nov 21 '05 #4

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

Similar topics

1
by: cmjman | last post by:
I have an issue where networkStream.Write doesn't perform its write downstream from my client program until the network stream is closed. I then see the data that was sent appear on the other side....
4
by: 0to60 | last post by:
I have a class that wraps a TcpClient object and manages all the async reading of the socket. It works really nice, and I use it all over the place. But there's this ONE INSTANCE where I create...
2
by: Nuno Magalhaes | last post by:
In a simple code I do something like this in a synchronous connection: -*server*----------------------------- ClientTcp=ListenerTcp.AcceptTcpClient(); NetworkStream nstream=ClientTcp.GetStream();...
0
by: Abubakar | last post by:
Hi, try { int x = ns.Read(readbuffer, 0, readbuffer.Length); } catch (System.IO.IOException ioexception) { UINotifications.ServerMessageDisplay(ioexception.ToString( )); }
0
by: Al Wilkerson | last post by:
Hey, Has anyone ever got a "Unable to read data from transport connected" message after reading data from a streamreader composed of a networkstream. For example: Server TcpListener...
2
by: PiotrKolodziej | last post by:
Hi I have a simple question. Here is the code related to my question: while (true) { if (tcpListenerServer.Pending() && !this.Disposing) { TcpClient tcpClient =...
5
by: | last post by:
I've got a basic "chat" infrastructure that can send objects across the wire, but I'm running into a few issues with trying to send multiple messages and things behaving differently in debug and...
7
by: littleIO | last post by:
Hi, I'm stuck on a very simple problem and just cant seem to get around it, little help would be much appreciated. I have a server which listens, receives calls, processes them and sends back the...
6
by: Ryan Liu | last post by:
Hi, I have some basic question about NetworkStream, can someone explain to me? Thanks a lot in advance! TcpClient has a GetStream() method return a NetworkStream for read and write. I...
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: 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
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
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
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...
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.