473,654 Members | 3,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Networkstream Returning Null Value

This is coming from a Windows 2003 Server to a HP Pocket PC (WinCE 2003)
over 802.11b. The device is on the Network and can be pinged, it can write
data to the Server stream - but not read the reverse.

I'd appreciate any help.

Server
------
Dim TcpC as New TcpListener(IPA ddress.Parse("1 92.168.1.5"), 8500)
TcpC.Start()
Dim tcpclient As TcpClient = TcpC.AcceptTcpC lient
Dim ns As NetworkStream = tcpclient.GetSt ream
Dim bytes() = System.Text.Enc oding.ASCII.Get Bytes("Testing Connection
Write")
ns.Write(bytes, 0, bytes.length)
tcpclient.Close ()
TcpC.Stop()

Mobile
------
Dim tcpc As New TcpClient
tcpc.Connect(IP Address.Parse(" 192.168.1.5"), 8500)
Dim bytes(30000) As Byte
Dim NS As NetworkStream = tcpc.GetStream
NS.Read(bytes, 0, CInt(tcpc.Recei veBufferSize))

it fails on the last line giving an ArgumentOutOfRa ngeException saying that
IsNothing(bytes ) = True.

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
2 1823
Hi Dustin,
Dim bytes(30000) As Byte
You forgot to instantiate your array:

---
Dim bytes(30000) As New Byte
---

Give that a go. Without the new operator your bytes variable will be
Nothing (as it hasn't been instantiated yet and hence the error. :)

Regards,
-Adam Goossens.

Dustin Brisebois via DotNetMonster.c om wrote: This is coming from a Windows 2003 Server to a HP Pocket PC (WinCE 2003)
over 802.11b. The device is on the Network and can be pinged, it can write
data to the Server stream - but not read the reverse.

I'd appreciate any help.

Server
------
Dim TcpC as New TcpListener(IPA ddress.Parse("1 92.168.1.5"), 8500)
TcpC.Start()
Dim tcpclient As TcpClient = TcpC.AcceptTcpC lient
Dim ns As NetworkStream = tcpclient.GetSt ream
Dim bytes() = System.Text.Enc oding.ASCII.Get Bytes("Testing Connection
Write")
ns.Write(bytes, 0, bytes.length)
tcpclient.Close ()
TcpC.Stop()

Mobile
------
Dim tcpc As New TcpClient
tcpc.Connect(IP Address.Parse(" 192.168.1.5"), 8500)
Dim bytes(30000) As Byte
Dim NS As NetworkStream = tcpc.GetStream
NS.Read(bytes, 0, CInt(tcpc.Recei veBufferSize))

it fails on the last line giving an ArgumentOutOfRa ngeException saying that
IsNothing(bytes ) = True.

Nov 21 '05 #2
Oops. I mis-read the exception type :) I think I need a bit more
sleep...my head feels groggy :P

You may have received more data than your array can handle (the
ArgumentOutOfRa nge exception is a good clue to that). You should only
read as much data as you have space to handle it.

Try something like this instead:

---
NS.Read(bytes, 0, bytes.Length)
---

Or, dimension your array to accomodate all of the data received:

---
Dim bytes(tcpc.Leng th) As Byte
---

As for my stupid comment about instantiating your array: ignore it. I
don't know what I was thinking - you can't instantiate arrays with New.
I must be tired.

Sorry :)
Regards,
-Adam.

Dustin Brisebois via DotNetMonster.c om wrote:
This is coming from a Windows 2003 Server to a HP Pocket PC (WinCE 2003)
over 802.11b. The device is on the Network and can be pinged, it can write
data to the Server stream - but not read the reverse.

I'd appreciate any help.

Server
------
Dim TcpC as New TcpListener(IPA ddress.Parse("1 92.168.1.5"), 8500)
TcpC.Start()
Dim tcpclient As TcpClient = TcpC.AcceptTcpC lient
Dim ns As NetworkStream = tcpclient.GetSt ream
Dim bytes() = System.Text.Enc oding.ASCII.Get Bytes("Testing Connection
Write")
ns.Write(bytes, 0, bytes.length)
tcpclient.Close ()
TcpC.Stop()

Mobile
------
Dim tcpc As New TcpClient
tcpc.Connect(IP Address.Parse(" 192.168.1.5"), 8500)
Dim bytes(30000) As Byte
Dim NS As NetworkStream = tcpc.GetStream
NS.Read(bytes, 0, CInt(tcpc.Recei veBufferSize))

it fails on the last line giving an ArgumentOutOfRa ngeException saying that
IsNothing(bytes ) = True.

Nov 21 '05 #3

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

Similar topics

11
1932
by: JKop | last post by:
AnyClass Blah() { AnyClass poo; return poo; } As we all know, in the above, the compiler is entitled to:
9
5197
by: Thomas Mlynarczyk | last post by:
Hi, It seems to be a generally adopted convention to have a function return FALSE in case of an error. But if a function is supposed to return a boolean anyway, one cannot distinguish anymore between the "normal" FALSE and the "error" FALSE. So why not using NULL instead to indicate an error? Are there drawbacks I am not aware of? Greetings, Thomas
7
6798
by: bjose21 | last post by:
Hello, I've been searching the web for quite some time to resolve the problem of "1/1/1900" returning in a datetime field in SQL that resulted from a blank (not NULL) value being passed to it through an ASP page. The solution is that a NULL value needs to passed to SQL from ASP. Thats fine...I understand the why the problem is happening and the solution around it. HOWEVER, I can't seem to get the proper syntax to work in the ASP...
0
1767
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: //=================================================================== // The table
4
7470
by: Rob | last post by:
Hi, I have a label that I'm trying to make invisible on the client side using the OnClientClick event for a button. In the javascript function I have the following code: var x = getElementById("ctl00_ContentPlaceHolder1_label"); x.Visible = true;
11
1836
Parul Bagadia
by: Parul Bagadia | last post by:
I m returning a value of pointer of a structure from one function to main; but whenever it comes in main it becomes NULL... i used another pointer in main and equated its value to returning pointer but its still becoming NULL. I also tried removing its initialization from main; but ivvain. So, what is to be donr to retain its value? Actually i want to use the same value in other function; which m calling from main.
1
7464
by: sbowman | last post by:
I have the following CASE statement in a view: (SELECT CASE WHEN ISNULL(.., NULL) = NULL THEN .(..) ELSE .(..) + ', ' + .. END) AS ContactNameAndTitle It works perfectly when dbo.tblContact.JobTitleID is NOT null. When it
3
2312
by: pbellem | last post by:
Is there a way to write a select that will return a null value for a row that does not exist? for example: Table A productId - type id - name - value 1 - 1 - Title - "Great Song" 1 - 2 - syntax - verb
2
2533
by: aaronharwood | last post by:
I have read dozens of existing responses on threads, that span the last 5 years or so, concerning this problem and while there are many solutions that appear to work for others - none work for me. I have some Javascript that is receiving an XML file from a Servlet. The problem is that the XMLResponse always returns a null value. Here is some the code snippet: ... function alertContents() { if (http_request.readyState == 4) { ...
0
8294
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
8816
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...
0
8709
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7309
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
6162
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
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1597
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.