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

Networkstream returns ArgumentOutOfRangeException

Since this issue encompasses so many things - I have to generally post it I
guess.

I'm building an application for a Wireless PDA - when it is connected to the
Network I tested a TCPListener & TCPClient connection from the Server to the
PDA. The connection allows me to Send from the PDA to the Server - but the
PDA will not read what the Server writes. I copied the exact information from
Microsofts Website on TCP basics - with some changes. Even disabled Firewall
Security - same. The PDA will download webpages, the Server can ping it - but
it will not receive.

Its an HP iPAQ rx3100 if that matters with Windows CE 4.2 2003 - Server is
running Windows 2003 Standard - and I am using Visual Studio 2003.NET to test
- the PDA also has OpenNETCF 1.2 with /cfAES pack.
Jul 21 '05 #1
7 2353
Dustin B <Du*****@discussions.microsoft.com> wrote:
Since this issue encompasses so many things - I have to generally post it I
guess.

I'm building an application for a Wireless PDA - when it is connected to the
Network I tested a TCPListener & TCPClient connection from the Server to the
PDA. The connection allows me to Send from the PDA to the Server - but the
PDA will not read what the Server writes. I copied the exact information from
Microsofts Website on TCP basics - with some changes. Even disabled Firewall
Security - same. The PDA will download webpages, the Server can ping it - but
it will not receive.

Its an HP iPAQ rx3100 if that matters with Windows CE 4.2 2003 - Server is
running Windows 2003 Standard - and I am using Visual Studio 2003.NET to test
- the PDA also has OpenNETCF 1.2 with /cfAES pack.


You haven't said exactly what happens, or posted any code.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2


"Jon Skeet [C# MVP]" wrote:
Dustin B <Du*****@discussions.microsoft.com> wrote:
Since this issue encompasses so many things - I have to generally post it I
guess.

I'm building an application for a Wireless PDA - when it is connected to the
Network I tested a TCPListener & TCPClient connection from the Server to the
PDA. The connection allows me to Send from the PDA to the Server - but the
PDA will not read what the Server writes. I copied the exact information from
Microsofts Website on TCP basics - with some changes. Even disabled Firewall
Security - same. The PDA will download webpages, the Server can ping it - but
it will not receive.

Its an HP iPAQ rx3100 if that matters with Windows CE 4.2 2003 - Server is
running Windows 2003 Standard - and I am using Visual Studio 2003.NET to test
- the PDA also has OpenNETCF 1.2 with /cfAES pack.


You haven't said exactly what happens, or posted any code.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Server
-------
Dim TcpC as New TcpListener(IPAddress.Parse("192.168.1.5"), 8500)
TcpC.Start()

Dim tcpclient as TcpClient = TcpC.AcceptTcpClient
Dim ns as NetworkStream = tcpclient.GetStream
Dim bytes() as Byte
bytes = System.Text.Encoding.ASCII.GetBytes("Testing Connection Write")
ns.Write(bytes, 0, bytes.length)
tcpclient.Close()
TcpC.Stop()
Client
------
Dim tcpc As New TcpClient
tcpc.Connect(IPAddress.Parse("192.168.1.5"), 8500)
Dim bytes(30000) As Byte
Dim NS As NetworkStream = tcpc.GetStream
NS.Read(bytes, 0, CInt(tcpc.ReceiveBufferSize))

bytes returns as IsNothing(bytes) = True
Jul 21 '05 #3
Dustin B <Du*****@discussions.microsoft.com> wrote:
Server
-------
Dim TcpC as New TcpListener(IPAddress.Parse("192.168.1.5"), 8500)
TcpC.Start()

Dim tcpclient as TcpClient = TcpC.AcceptTcpClient
Dim ns as NetworkStream = tcpclient.GetStream
Dim bytes() as Byte
bytes = System.Text.Encoding.ASCII.GetBytes("Testing Connection Write")
ns.Write(bytes, 0, bytes.length)
tcpclient.Close()
TcpC.Stop()
Client
------
Dim tcpc As New TcpClient
tcpc.Connect(IPAddress.Parse("192.168.1.5"), 8500)
Dim bytes(30000) As Byte
Dim NS As NetworkStream = tcpc.GetStream
NS.Read(bytes, 0, CInt(tcpc.ReceiveBufferSize))

bytes returns as IsNothing(bytes) = True


Please read
http://www.pobox.com/~skeet/csharp/incomplete.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4


"Jon Skeet [C# MVP]" wrote:
Dustin B <Du*****@discussions.microsoft.com> wrote:
Server
-------
Dim TcpC as New TcpListener(IPAddress.Parse("192.168.1.5"), 8500)
TcpC.Start()

Dim tcpclient as TcpClient = TcpC.AcceptTcpClient
Dim ns as NetworkStream = tcpclient.GetStream
Dim bytes() as Byte
bytes = System.Text.Encoding.ASCII.GetBytes("Testing Connection Write")
ns.Write(bytes, 0, bytes.length)
tcpclient.Close()
TcpC.Stop()
Client
------
Dim tcpc As New TcpClient
tcpc.Connect(IPAddress.Parse("192.168.1.5"), 8500)
Dim bytes(30000) As Byte
Dim NS As NetworkStream = tcpc.GetStream
NS.Read(bytes, 0, CInt(tcpc.ReceiveBufferSize))

bytes returns as IsNothing(bytes) = True


Please read
http://www.pobox.com/~skeet/csharp/incomplete.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


I am serious that's it. On the last line of the Client Script it returns the
ArgumentOutOfRangeException - the most I can figure is that the byte array
when returned is empty - however the Client does say there is Data Available.
I have two version the full one - not shown - and the test one (shown) both
return the same error. I have had the PDA unplugged from ActiveSync to test -
tested the Firewall/Router rewired the Network - nothing same error. I'm
almost tempted to think its hardware or another layer of the PDA but the PDA
is able to write to the stream if I swap the Client/Listener Read/Write
commands.
Jul 21 '05 #5
Dustin B <Du*****@discussions.microsoft.com> wrote:
Please read
http://www.pobox.com/~skeet/csharp/incomplete.html
I am serious that's it.


No it's not. You didn't post a complete program. If you don't believe
me, try cutting and pasting your code into an empty text editor, and
then compiling it without adding anything more.
On the last line of the Client Script it returns the
ArgumentOutOfRangeException


And what's the message of the ArgumentOutOfRangeException? It should at
least tell you what argument it is that's out of range.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #6


"Jon Skeet [C# MVP]" wrote:
Dustin B <Du*****@discussions.microsoft.com> wrote:
Please read
http://www.pobox.com/~skeet/csharp/incomplete.html


I am serious that's it.


No it's not. You didn't post a complete program. If you don't believe
me, try cutting and pasting your code into an empty text editor, and
then compiling it without adding anything more.
On the last line of the Client Script it returns the
ArgumentOutOfRangeException


And what's the message of the ArgumentOutOfRangeException? It should at
least tell you what argument it is that's out of range.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Well I took out the silly stuff like Imports and Sub New - but that was all
autocreated by VS.NET anyway. It never told me what the Argument was. But I
just found the solution anyway. Seems that it was being thrown by the
NetworkStream itself.

NetworkStream.Read(bytes as Byte[], position (as Integer), length (as
Integer)) as Integer

only after some digging did I notice the return at the end - as soon as I
captured the return somewhere - the String sent along the stream was
captured. Strange.
Jul 21 '05 #7
Dustin B <Du*****@discussions.microsoft.com> wrote:
I am serious that's it.
No it's not. You didn't post a complete program. If you don't believe
me, try cutting and pasting your code into an empty text editor, and
then compiling it without adding anything more.
On the last line of the Client Script it returns the
ArgumentOutOfRangeException


And what's the message of the ArgumentOutOfRangeException? It should at
least tell you what argument it is that's out of range.

Well I took out the silly stuff like Imports and Sub New - but that was all
autocreated by VS.NET anyway.


That's not silly stuff. It makes life *much* easier for someone to
reproduce the problem. I don't want to have to launch Visual Studio in
order to test your code - I want to be able to copy your code into a
text editor, compile it and run it. If it's going to take longer than
that, I'll move onto a message where someone is willing to follow
instructions to make it easier for me to help them - that way I get to
help more people.
It never told me what the Argument was.
Not in the message? Was there a message at all? You never posted it.
But I just found the solution anyway. Seems that it was being thrown
by the NetworkStream itself.

NetworkStream.Read(bytes as Byte[], position (as Integer), length (as
Integer)) as Integer

only after some digging did I notice the return at the end - as soon as I
captured the return somewhere - the String sent along the stream was
captured. Strange.


I don't see how using the return value could affect things at all. But
without a short but complete test program, I'm not going to bother to
investigate further...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #8

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

Similar topics

3
by: Darcy Ryan | last post by:
Greetings, I am having a problem trying to use the TcpClient and NetworkStream classes to connect to a POP3 server. My (simplified test) VB.NET code is as follows: Dim tcpclient As New...
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...
0
by: Hai Ly Hoang \(MT00KSTN\) | last post by:
Hi, FileStream.Read(buf, offset, siz) will return when reaching the end of file or a block (size siz) can be read from the file. In the case of NetworkStream, it's more confusing. Now, consider...
2
by: Srinivas R. Loka | last post by:
I have a TCP server to which a number of mobile devices connect. If a device disconnects(mostly no clean close as they usually lose cell coverage or shutdown), and the server then tries to send...
10
by: Sven Huijbrechts | last post by:
Hello, I need to send a couple of "NUL"s -> HEX value "00" on a networkstream.. This is the code we currently use to send string: Dim sendBytes As () =...
2
by: Dustin Brisebois via DotNetMonster.com | last post by:
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...
7
by: Dustin B | last post by:
Since this issue encompasses so many things - I have to generally post it I guess. I'm building an application for a Wireless PDA - when it is connected to the Network I tested a TCPListener &...
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...
8
by: Peter Bradley | last post by:
Hi, I wonder if anyone can help me out? I'm trying to implement an EPP (rfc4934 and rfc4930) client. So far I've managed to connect and authorise using an X509 Certificate. This should...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.