471,338 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 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 2236
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by 0to60 | last post: by
reply views Thread by Hai Ly Hoang \(MT00KSTN\) | last post: by
2 posts views Thread by Srinivas R. Loka | last post: by
10 posts views Thread by Sven Huijbrechts | last post: by
2 posts views Thread by Dustin Brisebois via DotNetMonster.com | last post: by
8 posts views Thread by Peter Bradley | last post: by

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.